2 Replies Latest reply on Oct 15, 2010 8:40 PM by satwika.chandra

    Classcast Exception using Oracle Blobs(10g) and JBoss 4.0

    satwika.chandra Newbie

      Hi all,

       

      Im using oracle 10g and JBoss 4.

       

      Im getting the following error :

       

       

       

      java.lang.ClassCastException

       

       

      : oracle.sql.BLOB

       

       

      Conn = DBConnector.getConnection();

      // Initially inserted an empty_blob() to data base

       

      //retrieving the record and locking it.

      PreparedStatement pStatement = conn.prepareStatement("Select ............... for Update")

      ResultSet result = pStatement.executeQuery();

      System.out.println(result.getClass().getName());

       

      result.next();

      BLOB blob =((OracleResultSet)result).getBLOB(1);

       

      OutputStream outStream = blob.setBinaryStream(1L);

       

      int size = blob.getBufferSize(); 

      byte[] buffer = new byte[size]; 

      int length = -1; 

       

      while ((length = inputStream.read(buffer)) != -1)

       

      outStream.write(buffer, 0, length);

      inputStream.close();

      outStream.close();

       

       

      Ive also tried casting my ResultSet obj with WrappedResultSet of org.jboss.resource.adapter package.

      This is also throwing a classcastexception.

       

      Please provide a solution.

       

      Thanks,

      Sat !