My Oracle Support Banner

12c PreparedStatement Parses SQL Incorrectly Causing java.lang.ArrayIndexOutOfBoundsException (Doc ID 2102983.1)

Last updated on NOVEMBER 09, 2021

Applies to:

JDBC - Version 12.1.0.2.0 to 12.1.0.2.0 [Release 12.1]
Information in this document applies to any platform.

Symptoms

When moving from the Oracle 11g R2 client to the 12c client in an application using JDBC OCI for connection, it is noticed that 2 queries are now parsed incorrectly. In one case, after preparing the statement, the metadata is fetched. The number of parameters reported is 1 and should be 2. Altering the whitespace slightly in the SQL will allow the query to parse correctly and report the correct number of parameters, which is 2.

In another case, after preparing the statement, the metadata is fetched. Fetching the metadata results in a java.lang.ArrayIndexOutOfBoundsException.

java.lang.ArrayIndexOutOfBoundsException: 128
at oracle.jdbc.driver.OracleParameterMetaDataParser.computeBasicInfo(OracleParameterMetaDataParser.java:327)
at oracle.jdbc.driver.OracleParameterMetaDataParser.getParameterMetaDataSql(OracleParameterMetaDataParser.java:433)
at oracle.jdbc.driver.OracleParameterMetaData.getParameterMetaData(OracleParameterMetaData.java:58)
at oracle.jdbc.driver.OraclePreparedStatement.getParameterMetaData(OraclePreparedStatement.java:12861)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.getParameterMetaData(OraclePreparedStatementWrapper.java:1551)

Again, altering the SQL by moving a condition which contains an IN clause to after the parameters in the SQL allows the SQL to parse cleanly and the metadata to report the correct number of parameters, which is 3.

Both of these queries were parsed correctly with the 11g R2 client.

 



Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.