Re: CLOB problem in JAVA

From: Jim McMahon <>
Date: Mon, 25 Jul 2005 22:46:03 GMT
Message-ID: <>

"Lig" <> wrote:

>Hi :
>I am getting a casting exception (java.lang.ClassCastException:
> when invoking the
>CLOB.createTemporary metehod. Extract of relevant lines shown below:
>ideas how I can resolve this?
>Oracle 9i
>WebSphere Ver 5.1
>import java.sql.Clob;
>import java.sql.Connection;
>import java.sql.CallableStatement;
>import java.sql.ResultSet;
>import java.sql.SQLException;
>import java.sql.Blob;
>import javax.sql.DataSource;
>import javax.naming.InitialContext;
>import javax.naming.Context;
>import javax.naming.NamingException;
>import java.util.List;
>import java.util.ArrayList;
>import java.sql.Types;
>import oracle.jdbc.OracleConnection;
>import oracle.jdbc.driver.*;
>import org.apache.commons.logging.Log;
>import org.apache.commons.logging.LogFactory;
>import oracle.sql.CLOB;
>Context jndiContext = new InitialContext();
>DataSource ds = (DataSource)jndiContext.lookup("java:comp/env/"
>Connection conn = ds.getConnection();
>tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION );
>Error Encountered: -
> java.lang.ClassCastException:

Without seeing the declaration for your tempClob object and looking up the return type of the CLOB.createTemporary() method this is only a guess and a hint:

You might be confusing the object type java.sql.Clob with the object type oracle.sql.CLOB - be sure which one you are using and check the docs for which one you need.

Hope this helps.


Being ordinary and nothing special is a full-time job. (Jim McMahon in real life) Received on Tue Jul 26 2005 - 00:46:03 CEST

Original text of this message