Skip to Content
author's profile photo Former Member
Former Member

JDBC error for CLOB


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 ( )


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

[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


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2005 at 04:03 PM

    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.



    Add a comment
    10|10000 characters needed characters exceeded

    • 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


Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.