Multiple datasouce for single report

0

I am not able to use diffrent datasouce for two same formatted report. It means it referes only last accessed report's datasource.

 I am not finding a way since last month. I am about to done with the development.

 

Please help me.

 

Thanks in advance.

virenptl40's picture
Joined: Jul 3 2014 - 6:43am
Last seen: 3 years 9 months ago

Jasper can only use one datasource. It provides no convenient way of using dynamic datasources. Generally you can use the user-defined datasource, but the code for doing this is not easy to write. Yet, this can be made easier if you use esProc to assist Jasper. The esProc script is as follows:

result ${sCode}.query("select * from sales where OrderDate>=? and OrderDate <=?",begin,end)

 

In a report, connect to Oracle database by assigning myDB1 to parameter sCode or MYSQL database by assigning myDB2 to the parameter.

 

For more complicated cases, you can write code for connecting to different datasources. For details, please refer to http://esproc.blogspot.com/2015/01/esproc-assists-report-development.html .

calculate.machine - 4 years 8 months ago

3 Answers:

0

Yes it is possible, but not recommended; everything but the main report connection must be defined within a parameter, and unless JNDI name spaces are configured for the various data sources, usernames and passwords must be stored within the JRXML itself; which for various reasons is not good design practice. Jasper is intended to use one datasource per report

 

This info was obtained via  "gertbeedfrobe"

 

Enjoy!

Java_Jasper's picture
Joined: Jan 17 2012 - 10:13am
Last seen: 3 years 9 months ago

Thanks a lot for the reply.
Exactly I am using one report per datasource. I have provided two different datasources for the two different report. But while executing this two reports in the same window, it is only referring one datasource for both the reports.
And If I execute only single report then it works fine.
Same I have tried with JNDI.
I am not finding a way how to resolve this. May be this is a limitation for jasperserver.

virenptl40 - 4 years 9 months ago

Hmm, so what you are saying is you have 2 reports each with a separate data source. And when you execute both in same window only one data source is available, however separate they behave as expected.

It sounds like you are taking about virtual data sources, which is in the commercial 5.0 version only. It allows multiple JDBC and/or JNDI data sources and use the combination as a single data source.

Hope this helps.

Java_Jasper - 4 years 8 months ago
0

Jasper can only use one datasource. It provides no convenient way of using dynamic datasources. Generally you can use the user-defined datasource, but the code for doing this is not easy to write. Yet, this can be made easier if you use esProc to assist Jasper. The esProc script is as follows:

result ${sCode}.query("select * from sales where OrderDate>=? and OrderDate <=?",begin,end)

 

In a report, connect to Oracle database by assigning myDB1 to parameter sCode or MYSQL database by assigning myDB2 to the parameter.

 

For more complicated cases, you can write code for connecting to different datasources. For details, please refer to http://esproc.blogspot.com/2015/01/esproc-assists-report-development.html .

calculate.machine's picture
Joined: Jan 13 2015 - 11:40pm
Last seen: 3 years 9 months ago
0

Yes, it is possible using vitual data sources:

https://community.jaspersoft.com/documentation/jasperreports-server-admi...

This is some more work currently being done to allow more advanced feature like combining data source from different adapters.

 

[UPDATED]

After reading your post one more time seems like you want to use dynamic data sources. In one case you might want to use datasource1 and in another case you want to use datasource2. If this is want you want, then you can make use of profile attributes, it allows you to define server-level, tenant-level and user-level attributes. For example user-level attributes each user could have different value for a attribute defined. Hence using that attribute you can create different data source.

https://community.jaspersoft.com/documentation/jasperreports-server-user...

HTH

nthapa's picture
463
Joined: Jan 24 2014 - 9:53am
Last seen: 3 years 3 months ago
Feedback
randomness