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.
3 Answers:
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!
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.
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 .
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
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 .