shashwat Posted March 27, 2013 Share Posted March 27, 2013 Hi All,I am new-bie in Jasper and I want to make a report which contains few field and 2 tables. For that I have provided the java beans, for table I am having a list in model and field (collection type) in template report.And through java code I am trying to generated the report.But I am getting this execption while filling the table. This is because we are using JRBeanCollectionDataSource while table uses subreport evalution which has the sql connection object.Please let me know how I should be setting the property for table datastore which can use the java bean.================= java.lang.ClassCastException: net.sf.jasperreports.engine.data.JRBeanCollectionDataSource cannot be cast to java.sql.Connectionat net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:369)at net.sf.jasperreports.components.table.fill.FillTableSubreport.evaluateSubreport(FillTableSubreport.java:95)at net.sf.jasperreports.components.table.fill.FillTable.evaluate(FillTable.java:106)at net.sf.jasperreports.engine.fill.JRFillComponentElement.evaluate(JRFillComponentElement.java:88)at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:457)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2037)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281)at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144) =================ThanksShashwat Link to comment Share on other sites More sharing options...
Solution sanbez Posted March 29, 2013 Solution Share Posted March 29, 2013 Set in main report properties for subreport: Connection Type = Use a datasource expression Data Source Expression = (like this:)new JRBeanCollectionDataSource(myCollection) Check that you don't put DataSourceExpression into "ConnectionType" (see yuor error): net.sf.jasperreports.engine.data.JRBeanCollectionDataSource cannot be cast to java.sql.Connection Link to comment Share on other sites More sharing options...
shashwat Posted April 16, 2013 Author Share Posted April 16, 2013 Thanks :) Link to comment Share on other sites More sharing options...
shashwat Posted April 16, 2013 Author Share Posted April 16, 2013 Basically it worked when I used dataSourceExpression by default iReport create ConnectionExpression Link to comment Share on other sites More sharing options...
endypark Posted April 3, 2018 Share Posted April 3, 2018 Change your iReport template:Change the Subreport.properties.connectionType from connection-expression to datasource-expression. Link to comment Share on other sites More sharing options...
endypark Posted April 3, 2018 Share Posted April 3, 2018 change the iReport template: change the subreport.properties.connectionType from connection-expression to datasource-expression. 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