kaung_1 Posted October 17, 2016 Share Posted October 17, 2016 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. http://community.jaspersoft.com/documentation/jasperreports-server-user-guide/defining-query 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 More sharing options...
akosolapov83 Posted October 17, 2016 Share Posted October 17, 2016 You can pass your sql query as string parameter. And then use it like this:<queryString><![CDATA[$P!{SQL_QUERY}]]></queryString> Link to comment Share on other sites More sharing options...
kaung_1 Posted October 17, 2016 Author Share Posted October 17, 2016 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 More sharing options...
reportdev Posted October 17, 2016 Share Posted October 17, 2016 Jasper Server supports using multiple databases on a single report.Default Data adapters Create a datasource xml file with username, password and connection stringsPlace your datasource xml file on the Tomcat webapps directory and related jdbc driver in the lib folder.On the Report Dataset properties - default data adapter, reference the datasource xml file on the webapps directory. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now