I'm studying iReport Design and I started using Connection at my fillReport. Until then, it's ok. The problem is that, now, I'm using Collection, with the commands:
List<Sales> sales = new SalesDAO().getSalesByDate( new SimpleDateFormat("yyyyMMdd").parse("20180101"), new SimpleDateFormat("yyyyMMdd").parse("20180131") ); JRDataSource dataSource = new JRBeanCollectionDataSource(sales);
In those way, when I try execute, it's show me the following error:
WARNING: The supplied java.sql.Connection object is null.
1 Answer:
You need either to pass the connection expression or the data source expression to the subreport. Since your subreport is not SQL based and is instead bean based so you'll need to bind the subreport to bean data source using the data source expression. Try something like this:
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{fieldNameToBeUsed})]]></dataSourceExpression>
Here is a good stackoverflow post about this:
https://stackoverflow.com/questions/11949333/passing-the-list-of-primiti...