Subreport with iReport and Java - The supplied java.sql.Connection object is null

0

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.

jorgew.moura's picture
Joined: Feb 14 2018 - 11:33am
Last seen: 2 months 3 weeks ago

1 Answer:

0

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

Friendly User's picture
Joined: Oct 8 2009 - 5:59am
Last seen: 6 hours 29 min ago
Feedback