java.lang.ClassCastException

I get the exception: java.lang.ClassCastException

while reading a blob (Oracle + tomcat using connection pooling)

Statement stmt = connection.createStatement();

ResultSet lobDetails = stmt.executeQuery("SELECT MY_BLOB FROM BLOB_TAB WHERE BLOB_ID = 1 FOR UPDATE");

if( lobDetails.next() ) {

Blob mapBlob = lobDetails.getBlob(1);

OutputStream blobOutputStream = ((oracle.sql.BLOB)mapBlob).getBinaryOutputStream(); // exception is thrown

<p>Please help!!

[513 byte] By [aimueller] at [2007-9-30 13:43:24]
# 1

Your mapBlob variable refers to an object that is not an oracle.sql.BLOB object.

If you are using Java 1.4 or later I would suggest not casting the object, and instead use the setBinaryStream() method of java.sql.Blob to get an OutputStream that allows you to write to the Blob. Otherwise, to find out what class of object you are getting,System.out.println(mapBlob.getClass().getName());

PC²

DrClap at 2007-7-4 22:46:12 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...