Jump to content

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


jorgew.moura

Recommended Posts

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.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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-primitive-type-objects-as-datasource-for-subreport

Link to comment
Share on other sites

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