IBM Support

java.lang.ArrayIndexOutOfBoundsException on the IBM Data Server Driver for JDBC and SQLJ stack

Technote (troubleshooting)


Problem(Abstract)

java.lang.ArrayIndexOutOfBoundsException is thrown on the IBM Data Server Driver for JDBC and SQLJ stack when ALTER TABLE modifies a PreparedStatement object's underlying table

Symptom

When a JDBC application that uses IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to query a table on a Db2 for z/OS data server using a PreparedStatement object, and another application alters the table that is being queried, a java.lang.ArrayIndexOutOfBoundsException is thrown on the driver stack.

Example of an affected JDBC driver stack:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 48

at com.ibm.db2.jcc.t2zos.b.y(b.java:274)

at com.ibm.db2.jcc.t2zos.b.mb(b.java:110)

at com.ibm.db2.jcc.t2zos.b.b(b.java:83)

at com.ibm.db2.jcc.am.mc.a(mc.java:263)

at com.ibm.db2.jcc.am.ResultSet.nextX(ResultSet.java:443)

at com.ibm.db2.jcc.am.ResultSet.next(ResultSet.java:371)

at select_pm47130.main(select_pm47130.java:68)

...

Note that because the JDBC driver code is obfuscated, the stack might look different for different driver versions.


Cause

To improve performance, when a JDBC application with a type 2 connection uses a PreparedStatement object to query a table, the driver caches the table's metadata information for future reuse. If another application changes the table's definition after the PreparedStatement object is created, the PreparedStatement object might no longer be valid for querying the table.


Diagnosing the problem

The deobfuscated stack trace shows that an ArrayIndexOutOfBoundsException is raised by the T2zosCursor.readFdocaOneByte method.

Resolving the problem

Disable limited block fetch by setting global configuration property db2.jcc.override.enableT2zosLBF or Connection and DataSource property enableT2zosLBF to 2.

Document information

More support for: DB2 for z/OS
SQLJ/JDBC

Software version: 8.0, 9.0, 10.0, 11.0, 12.0

Operating system(s): z/OS

Software edition: All Editions

Reference #: 2014453

Modified date: 09 March 2018


Translate this page: