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

$P{REPORT_CONNECTION} as subreport connection


jvencebi

Recommended Posts

Hi everybody !!!

I have a master report with several subreports. In the subreport properties put the Connection expression as $P{REPORT_CONNECTION} . When the report is run in iReport both reports get data but when the master report is called from a zk controller the master gets data, the subreport does not.

I found a thread with this same subject in

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=11772

but when the query is deleted in the master report the subreport does not show data in iReport.

Note: Since we are using zk's jasperreport tag, we had to create a class implementing JRDataSource wich receives the connection and the jasper report .

Please, help me know if there is a version bug or maybe I'm doing something wrong.

 

Juan

Code:
    public ClassImplementingJRDataSource(Connection conn,JasperReport         jasperReport,Map<String ,Object> params){      this.conn = conn;      m_nIdx = -1;      sql = jasperReport.getQuery().getText();      sql = sql.replaceAll("\\$P\\{infoId\\}", params.get("infoId").toString());      sql = sql.replaceAll("\\$P\\{coopType\\}", "'"+params.get("coopType").toString()+"'");    try {      stmt = this.conn.createStatement();            rs = stmt.executeQuery(sql);    } catch (SQLException e) {      e.printStackTrace();    }              }
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

It's alive !!! I found in another thread something to pass the connection as a parameter:

parameters.put("REPORT_CONNECTION",conn);// conn is a java.sql.Connection object

and it's working now.

The thread with the information is in:

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=55312

See you later,

Juan

Code:
Map<String, Object> params = new HashMap<String, Object>();params.put("SUBREPORT_DIR", urreportpathhere);params.put("SUBREPORTDATASOURCE", urdatasourcehere);JasperPrint print =JasperUtil.fillReport(mainreportpath, params, mainreportdatasource);

Post Edited by jvencebi at 10/05/2010 17:47
Link to comment
Share on other sites

  • 1 month later...

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