Error "java.lang.ClassCastException" When Inserting a CLOB into Database Using JNDI (Doc ID 367365.1)

Last updated on DECEMBER 01, 2011

Applies to:

JDBC - Version: 9.2.0.5 to 10.1.0.5 - Release: 9.2 to 10.1
Information in this document applies to any platform.

Symptoms

Problem: using JNDI lookup connection

dataSource = (DataSource) envContext.lookup(VstudioKey.VSTUDIO_DATA_SOURCE);
connection = dataSource.getConnection();

Running the code customer is getting a casting error for the connection class.

ERROR
java.lang.ClassCastException
at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin(OracleConnection.java:5192)
at oracle.sql.CLOB.createTemporary(CLOB.java:1009)
at oracle.sql.CLOB.createTemporary(CLOB.java:956)
at com.rogers.vstudio.model.autoTransfer.InsertXML2DB.invoke(InsertXML2DB.java:67)
at com.rogers.vstudio.logic.autoTransfer.FileMgr.insertXML2DB(FileMgr.java:156)
at com.rogers.vstudio.servlet.autoTransfer.AutoTransfer.doGet(AutoTransfer.java:114)
at com.rogers.vstudio.servlet.autoTransfer.AutoTransfer.doPost(AutoTransfer.java:183)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



The error comes from the following code:
clob = CLOB.createTemporary(this.connection, true, CLOB.DURATION_SESSION);


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