Skip to Content
0
Former Member
Dec 03, 2011 at 06:40 AM

setDataSource causes java.lang.AssertionError

90 Views

Good day,

Can anybody please tell me why the code below does not work, or how I can find what is causing the exception?

I get a "java.lang.AssertionError" exception the moment I try to set the data source, but I cannot find more information about the problem.

I've looped over the ResultSet before the assignment and it does have data.

(I'm using Netbeans, but is a bit new to it and Java.)

Any help would be much appreciated.

Thank you in advance,

Marius

//Open report.
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(sourceRpt, 0);

// Set data source.
Tables tables = reportClientDoc.getDatabaseController().getDatabase().getTables();
for (int i = 0; i < tables.size(); i++) {
    ITable origTable = tables.getTable(i);

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:CSV_DSN");
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select * from " + origTable.getName());
    String tableAlias = reportClientDoc.getDatabaseController().getDatabase().getTables().getTable(i).getAlias();

    // !!!!! Get "java.lang.AssertionError" here !!!!!
    reportClientDoc.getDatabaseController().setDataSource(rs, tableAlias, tableAlias + "_rs");
}

//Export report and obtain an input stream that can be written to disk.
ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream) reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);

//Release report.
reportClientDoc.close();