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

How to use external query for a sub-report?


kaung_1

Recommended Posts

I am trying to use external queries to create a report(s) that can support multiple SQL databases - mysql and oracle. My idea is I will create multiple queries - one for each database type, and a single reportUnit. Depending on which db type a customer has, I will link the right queries to the reportUnit. 

 

But my reportUnit contains subreports and I cannot find a way to set an external query to a subreport. I can set only one external query to a reportUnit and that query seem to override only the main_jrxml of the reportUnit. SubReports are not affected by external query.

 

Here, I find docs about external queries but there is no mention how it behaves with subreports.


 

I tried the following:

* If only I could pass a report's query to a subreport via subreport tag, it would be a solution. But subreports tag only support passing report connection but not query. 

 

There seem to be no other way to me. Is there any way that I can externalize they query from a subreport? Thanks in advance. 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

That SQL_QUERY string itself will contain parameters. e.g. If my report is to get all users from a certain country, there will be a "where users = $P{country}" somewhere in that SQL_QUERY string. Would jasper further substitute these paramters or will the string get sent to database lterally as it is? Would be amazing if substituation happens.... (I'll test it out soon but I doubt parameter substitution will happen)

 

Link to comment
Share on other sites

Jasper Server supports using multiple databases on a single report.

Default Data adapters 

  1. Create a datasource xml file with username, password and connection strings
  2. Place your datasource xml file on the Tomcat webapps directory and related jdbc driver in the lib folder.
  3. On the Report Dataset properties - default data adapter, reference the datasource xml file on the webapps directory. 

 

 

 

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...