Jump to content
We've recently updated our Privacy Statement, available here ×

Multiple datasouce for single report


virenptl40

Recommended Posts

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

  • 3 weeks later...

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 .


Link to comment
Share on other sites

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 .


Link to comment
Share on other sites

  • 2 weeks later...

Yes, it is possible using vitual data sources:

https://community.jaspersoft.com/documentation/jasperreports-server-administration-guide/v561/virtual-data-sources

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-guide/profile-attributes

HTH

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...