我是JasperReports的新手。
我有一个作为参数传递给主报告的结果集。从主报告中,我需要将它作为数据源传递给我的子报告。
param = super.getParam(param, "MY_RESULT_SET", resultSet);
JasperPrint jasperPrint = JasperFillManager.fillReport("myJasper.jasper", param, dataSource);
myJasper.jrxml的片段:
<parameter name="MY_RESULT_SET" class="java.sql.ResultSet"/>
<subreport>
<reportElement x="285" y="0" width="270" height="20"/>
<dataSourceExpression><![CDATA[$P{MY_RESULT_SET}]]></dataSourceExpression>
<subreportExpression><![CDATA["mySubreport.jasper"]]></subreportExpression>
</subreport>
如上所述,我得到以下异常
java.lang.ClassCastException: com.mysql.jdbc.JDBC4ResultSet cannot be cast to net.sf.jasperreports.engine.JRDataSource
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:356)
at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:275)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2021)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:755)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:265)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:765)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:84)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:540)
谁能指导我?