CLOB problem in JAVA  
Author Message
Lig





PostPosted: 2005-7-26 4:50:00 Top

java-programmer, CLOB problem in JAVA Hi :

I am getting a casting exception (java.lang.ClassCastException:
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection) when invoking the
CLOB.createTemporary metehod. Extract of relevant lines shown below:
Any
ideas how I can resolve this?

Versions:

Oracle 9i
WebSphere Ver 5.1

Cheers
Lig



import java.io.Writer;
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/"
+s_dataSource);
Connection conn = ds.getConnection();
tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION );

Error Encountered: -
java.lang.ClassCastException:
com.ibm.ws.rsadapter.jdbc.WSJdbcConnection

 
jp_mcmahon





PostPosted: 2005-7-26 6:46:00 Top

java-programmer >> CLOB problem in JAVA "Lig" <email***@***.com> wrote:

>Hi :
>
>I am getting a casting exception (java.lang.ClassCastException:
>com.ibm.ws.rsadapter.jdbc.WSJdbcConnection) when invoking the
>CLOB.createTemporary metehod. Extract of relevant lines shown below:
>Any
>ideas how I can resolve this?
>
>Versions:
>
>Oracle 9i
>WebSphere Ver 5.1
>
>Cheers
>Lig
>
>
>
>import java.io.Writer;
>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/"
>+s_dataSource);
>Connection conn = ds.getConnection();
>tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION );
>
>Error Encountered: -
> java.lang.ClassCastException:
>com.ibm.ws.rsadapter.jdbc.WSJdbcConnection
>


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.

Jim


Being ordinary and nothing special is a full-time job.
email***@***.com (Jim McMahon in real life)
 
joeNOSPAM@BEA.com





PostPosted: 2005-7-26 6:48:00 Top

java-programmer >> CLOB problem in JAVA Hi, yes. This is because Oracle did the amateurish thing of making
a lot of it's nonstandard extensions to JDBC without making
Interfaces for the extra calls, and also exposing methods with
deceptive signatures. In this case the createTemporary() method
*says* it takes a java.sql.Connection, which the WebSphere
wrapper *is*, but the method *really* needs a direct naked
oracle driver connection because somewhere deeper in the
internals, it's casting the connection to a concrete oracle class
to be able to call one of those nonstandard connection methods.
Besides yelling at Oracle, your only real recourse is to stick
to only standard JDBC calls, or use only direct Oracle connections
for these calls, outside the scope, purview, and wrapping of WebSphere.
WebSphere might have a call you could make in this context
to get a handle to the underlying real oracle connection, in which
cas you could pass that to the Clob call. I know BEA's WebLogic
does...
Joe Weinstein at BEA Systems

 
 
Dariusz Dudek





PostPosted: 2005-7-26 15:45:00 Top

java-programmer >> CLOB problem in JAVA You can try diffrent way to create CLOB in database.

INSERT INTO TAB(ID,TXT)
VALUES(1,EMPTY_CLOB())
java.sql.ResultSet rset = ...
oracle.sql.CLOB lob = (oracle.sql.CLOB )rset.getClob(2);
OutputStream lobOut = lob.getBinaryOutputStream();


Dariusz Dudek