darth_fader Posted September 16, 2011 Share Posted September 16, 2011 You have a parent report with multiple subreports, A, B, C. The parent report and A, B use the same datasource, C needs to use a different one. Simply pass the connection needed by C as a parameter to the parent report, then pass that parameter to the subreport as the connection expression, as follows.in java, put the connection in a the jasperParameters map: jasperParameters.put("oddBallConnection", connection); in jrxml, add the following to the parent report: <import value="java.sql.Connection"/> <parameter name="oddBallConnection" class="java.sql.Connection"/> add the following to the subreport reference <subreport> as follows: <connectionExpression><![CDATA[$P{oddBallConnection}]]></connectionExpression> You can use as many datasources/connections in jasper as you need. I referred to the forums when I tried to solve this, and found various responses to the same question. Hope this helps. Link to comment Share on other sites More sharing options...
kcd Posted October 3, 2011 Share Posted October 3, 2011 Nice thanks. Any chance you managed to get A and B to use the same datasource AND only query the database once? That is a problem I am facing. Link to comment Share on other sites More sharing options...
darth_fader Posted October 3, 2011 Author Share Posted October 3, 2011 Haven't had that situation come up yet; think a subreport is going to expect it's own query/fields etc. If A and B use the same datasource and query, then maybe subreport B isn't necessary. Maybe with some creative thinking you could get the data in the format you need in one report? Possibly use the summary band, or a table/frame/etc.? Link to comment Share on other sites More sharing options...
kcd Posted October 3, 2011 Share Posted October 3, 2011 Unless I am misunderstanding something (very possible!) the scenario isn't so unlikely if you use tables, which seem to act just like a subreport, and want a chart too (but not at the bottom)... But yes my problem is quite different to just A and B subreports. I'm sure there is another method but anyway that is all covered in my post here. http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=92333 Thanks for replying, don't mean to hijack your post. 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