Using Non-Default Constructor with SQL Object Type Fails With "Inconsistent java and sql object types"

(Doc ID 2360186.1)

Last updated on FEBRUARY 15, 2018

Applies to:

JDBC - Version 11.2.0.1.0 to 12.2.0.0.0 [Release 11.2 to 12c]
Information in this document applies to any platform.

Symptoms

Given the following scenario:

* Using a SQL object type
* Using an associated array of that type
* After the fact, a new attribute is added to that object type
* A non-default constructor is created to give the option of filling in a default value for that new attribute.

Working with that non-default constructor is successful when it is called directly from PL/SQL using SQL*Plus.
However, that non-default constructor fails with the following error when called from JDBC:

java.sql.SQLException: Inconsistent java and sql object types
at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:711)
at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1298)
at oracle.sql.STRUCT.(STRUCT.java:167)
at oracle.jdbc.driver.PhysicalConnection.createStruct(PhysicalConnection.java:9194)
at com.db.stm.service.StateServiceImpl.createStateStruct(StateServiceImpl.java:251)
at com.db.stm.service.StateServiceImpl.getStateStruct(StateServiceImpl.java:247)
at com.db.stm.service.StateServiceImpl.populateOracleStruct(StateServiceImpl.java:236)
at com.db.stm.service.StateServiceImpl.createStateRecordsStruct(StateServiceImpl.java:177)


The problem reproduces with the 11.2.0.4, 12.1.0.2, and 12.2.0.1 JDBC driver.

Changes

 

Cause

Sign In with your My Oracle Support account

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

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms