Unfortunately, iReport doesn’t have a field definition for Clobs and the Informix JDBC will report the Clob data field as a String when asked. There is a solution to this dilemma. A ClobInflator class was created in the com.jaspersoft.ps.maricopa package. Sample usage inside your custom datasource:

for (; rs.next();) {
ArrayList smallList = new ArrayList();
String clobString = “”;
for (int i = 1; i < colCount + 1; i++) {
Object nextObject = rs.getObject(i);
if (i == CLOB_FIELD_INDEX) {
java.io.InputStream ip = rs.getAsciiStream(i);
ClobInflater cI = new ClobInflater();
clobString = cI.getClobString(ip);
}
if (i == CLOB_FIELD_INDEX) {
smallList.add(clobString);
}
else {
smallList.add(nextObject);
}
}
queryDataList.add(smallList);
}

Of course this depends on you knowing that your field is a Clob type. These types are labled as “text” types in Informix.

 

1 comment on “Clob data field handling in IReport

Leave a Reply

Your email address will not be published. Required fields are marked *