I have the same problem. <br />
It happen any time that you try to create an oracle temporary CLOB or BLOB.<br />
The oracle method is defined as BLOB.createTemporary(Connection con, boolean cache, in duration)<br />
<br />
Inside this method Oracle's JDBC driver casts the connection object to OracleConnection. This works fine when ever you don't use WAS datasource with connection pool.<br />
<br />
As soon as WAS datasoruce is use the cast becomes a problem because the WAS datasource returns a WAS specific connection wrapper WSjdbcConnection. <br />
<br />
The following code cab be added to a simple servlet to show the failure. <br />
boolean runningInWAS = true;<br />
if( runningInWAS ){<br />
Context context = null;<br />
try { <br />
context = new InitialContext(); <br />
} catch(NamingException e) {<br />
throw new ServletException("Could not get Initial Context");<br />
}<br />
<br />
// datasource lookup<br />
try<br />
{<br />
DataSource datasource = <br />
(DataSource)context.lookup("java:comp/env/jdbc/WASDatasource");<br />
<br />
Connection conn = datasource.getConnection();<br />
//The following line trows and error when running in WebSphere env. <br />
BLOB sBlob = BLOB.createTemporary(conn, true, BLOB.DURATION_SESSION);<br />
conn.close();<br />
} catch(SQLException sql){<br />
<br />
} catch(NamingException e) {<br />
log.error("JNDI lookup failed for datasource for RM database: " <br />
+ RMConstants.JNDI_DATASOURCE_RMDB, e); <br />
throw new ServletException("Could not get connection to Resource Manager datasource: "<br />
+ RMConstants.JNDI_DATASOURCE_RMDB);<br />
}<br />
}else{ // running stand alone, is OK <br />
try{<br />
Class cObj = Class.forName("oracle.jdbc.pool.OracleDataSource");<br />
DataSource datasource = = (DataSource) cObj.newInstance();<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setServerName("
host.svl.ibm.com");<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setDriverType("thin");<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setDatabaseName("myDB");<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setPortNumber(1521);<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setUser("scott");<br />
((oracle.jdbc.pool.OracleDataSource) datasource).setPassword("tigger");<br />
<br />
BLOB sBlob = BLOB.createTemporary(datasource.getConnection(), true, BLOB.DURATION_SESSION);<br />
} catch(SQLException sql){<br />
}<br />
}<br />
<br />
I have seen a suggestion to use WSjdbcUtil.getNativeConnection(), but that has the problem I need to include WAS jar files in our build environment an it does not work when we deploy on other Application servers. <br />
<br />
Can any one provide a better workaround to this problem?