How to use Attributes for dynamic data source ?

Hi,

I followed the Admin guide and tested with a new user on JRS 6.4.0 and JRS 7.5.0 and I get the same error :

"Attribute 'host' is not defined in the User Profile."

Or if the host is defined in the Server profile :

"Attribute 'host' is not defined in the server Profile."

2020-01-21 17:27:10,545 ERROR ProfileAttributesResolverImpl,http-apr-8080-exec-12:307 - Erreur de substitution dans la ressource /datasources/JDBC_PGDH, champ 'url'. Attribut 'host' non défini dans le Server Profile.

Here is the URL : jdbc:postgresql://{attribute('host','Server')}:{attribute('port','Server')}/{attribute('db','Server')}

If anyone has an idea ?

Regards,

Yann

 

Attachments: 
yann22580's picture
570
Joined: Apr 29 2015 - 1:10am
Last seen: 4 months 3 weeks ago

4 Answers:

Here is how you can use Attributes in Data Source definitions: https://community.jaspersoft.com/documentation/tibco-jasperreports-server-administrator-guide/v750/attributes-data-source-definitions

When you do something like "{attribute('host','Server')}" a value for the "host" attribute needs to be in the Server Attributes (Manage > Server Settings > Server Attributes) need to be set.

"{attribute('someKey','User')}" implies a "someKey" needs to be in the User Atributes of the currently logged in user.

"{attribute('someKey')}" implies that the Server will search for a "someKey" attribute in the following order: User (logged in user),  Organization hierarchy of logged in user, Server.

Sherman

swood_1's picture
9054
Joined: Nov 15 2012 - 10:47am
Last seen: 2 years 10 months ago

Thanks to you Sherman but what you explain is exactly what I did. I precised I followed the Admin guide and create a new user for the tests.

I tried with the attributes at the user level or server level, both reacts the same with the error below : " 'host' attribute not defined at User/Server profile".

I attached another screenshot of the user attributes.

Would you have another idea ?

Attachments: 
AttachmentSize
Image icon user_attribute.png17.61 KB
yann22580's picture
570
Joined: Apr 29 2015 - 1:10am
Last seen: 4 months 3 weeks ago

Hi,

in Manage > Server Settings > Server Attributes menu you should add atrbiutes using their name/key, that is just

userName
password

Syntax like {attribute('host','Server')}  should be used in Da tasource definition only:

jdbc:postgresql://{attribute('host','Server')}:{attribute('port','Server')}/{attribute('db','Server')}

Best regards,
Andriy

asimkin's picture
27355
Joined: Jun 16 2014 - 6:30am
Last seen: 2 years 4 months ago

Hi Andriy,

Thanks for your answer, it works.

Ttoo bad it tooks so long just because of that..

Regards,

Yann

 

yann22580's picture
570
Joined: Apr 29 2015 - 1:10am
Last seen: 4 months 3 weeks ago
Feedback