BIRT generates error while reading Long Datatype

If you are reading a Long datatype in a data set in a BIRT report you might receive the below error while executing the report in the fetch function is executed in the report.


Fri Mar 26 16:02:58 GST 2021  ERROR  getString(LONGDATATYPECOL) failed.
java.sql.SQLException: Stream has already been closed
at oracle.jdbc.driver.LongAccessor.getBytesInternal(LongAccessor.java:131)
at oracle.jdbc.driver.Accessor.getBytes(Accessor.java:951)
at oracle.jdbc.driver.LongAccessor.getString(LongAccessor.java:166)
at oracle.jdbc.driver.GeneratedStatement.getString(GeneratedStatement.java:327)
at oracle.jdbc.driver.GeneratedScrollableResultSet.getString(GeneratedScrollableResultSet.java:882)
at oracle.jdbc.driver.GeneratedResultSet.getString(GeneratedResultSet.java:1460)
at com.ibm.tivoli.maximo.report.script.MXReportResultSet.getString(MXReportResultSet.java:541)
at com.ibm.tivoli.maximo.report.script.MXReportDataSetImpl.getString(MXReportDataSetImpl.java:434)
at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.c23._c1(/report/data-sets/script-data-set[@id="1662"]/method[@name="fetch"]:8).... 

This error caused by the Oracle SQL driver closing the stream when reading the recordset data for Long datatypes if any other operation is performed on the recordset before reading the Long Datatype column.

More info can be found here in Oracale documentation

https://docs.oracle.com/cd/A81042_01/DOC/java.816/a81354/basic4.htm

 

“If you do not use the SELECT-list order to access data, then you can lose the stream data. That is, if you bypass the stream data column and access data in a column that follows it, the stream data will be lost. For example, if you try to access the data for the NUMBER column before reading the data from the stream data column, the JDBC driver first reads then discards the streaming data automatically. This can be very inefficient if the LONG column contains a large amount of data.”


To avoid this error make sure you fetch the LONGDATATYPE column in the fetch function before reading any other column. 


if (!maximoDataSet.fetch())

return (false);


// Add a line for each output column

// The specific get method should match the data type of the output column.


row["LONGDATATYPEATTR1"] = maximoDataSet.getString("LONGDATATYPEATTR1"); // Read this column first

row["ATTR1"] = maximoDataSet.getString("ATTR1");

row["ATTR2"] = maximoDataSet.getString("ATTR2");

row["ATTR3"] = maximoDataSet.getTimestamp("ATTR3");

row["ATTR4"] = maximoDataSet.getInt("ATTR4");



Comments

Popular posts from this blog

BMXAA6713E - The record could not be retrieved from the database. Error

Rebuilding Maximo Text Indexes due to Query performance issues

List of things checked by Maximo Integrity checker