cancel
Showing results for 
Search instead for 
Did you mean: 

JDBC error for CLOB

Former Member
0 Kudos

Hi,

I face the following error, i use the oracle jdbc driver as db driver and i use the same ojdbc14.jar file as the project library, but when i try to cast the clob object return from resutlset it throw me class cast exception, i did print out the class name it shown oracle.sql.CLOB, but when i cast the object to oracle.sql.CLOB it still show me the error.

Do you have any idea what is wrong?

====================// java code

import java.sql.Clob;

import oracle.sql.CLOB;

Clob clob = null;

if ( resultSet.next() )

{

clob = resultSet.getClob( 1 );

logger.debug( "resultSet.getClass() is " + resultSet.getClass() );

logger.debug( "clob.getClass() is " + clob.getClass() );

logger.debug( "clob is " + clob );

logger.debug( "(clob instanceof oracle.sql.CLOB) is " + (clob instanceof oracle.sql.CLOB));

CLOB oraClob = (CLOB)clob; // this is where the class cast exception occur

====================// log file

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- selectUpdateStatement is com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper@d5b222

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- resultSet.getClass() is class oracle.jdbc.driver.OracleResultSetImpl

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob.getClass() is class oracle.sql.CLOB

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- clob is oracle.sql.CLOB@1a21321

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- (clob instanceof oracle.sql.CLOB) is false

[10/01/2005 15:51:26] b.crrs.common.CRRSParamServlet -- DEBUG -- error

java.lang.ClassCastException

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Yew Jin Kang,

just an idea: I had similar problems some time ago that came from different classloaders.

This would mean that when creating the instance clob another class loader for oracle.sql.CLOB might be valid than when your coding is executed.

In this case the classes are assumed to be different.

I am not an expert on this, and can also give no advice how to proceed, when my idea is true.

However, it may give you a hint.

Greetings

Stephan

detlev_beutner
Active Contributor
0 Kudos

Hi,

as Stephan wrote, this is almost for sure a classloader problem. To check, just ask the one class as well as the class of the object to be casted for it's classloader (just printing the classloader, ie the java object id). If they are different, then that's it.

Now: How to proceed. Check for different JARs deployed from root. It might be possible that both classes in question do not belong to two JARs with the same name, so also watch out (by the help of WinRAR for example) for the class itself within all JARs.

Once you got the problem. you have to check how you could use the class from the JAR the retrieved object came from (maybe you just don't have to deploy the drivers again).

Hope it helps

Detlev