6 Replies Latest reply on Feb 28, 2002 6:36 PM by David Jencks

    EJB-BLOB problem.

    rohit Newbie

      I am trying to insert a blob object in the oracle 8i database using ejb session bean .i am using the BLOB class of oracle.sql package however it throws the following exception
      java.lang.ClassCastException: org.jboss.pool.jdbc.ResultSetInPool.

      when the method is executed.

      i am using the following code.

      //strPk is the primary key.

      BLOB blob=((OracleResultSet)rs).getBLOB(1);
      //error is thrown on above line
      FileInputStream instream=new FileInputStream(appRef.getRefMaterial());//returns a file object
      OutputStream outStream=blob.getBinaryOutputStream();
      int size=blob.getBufferSize();
      byte buffer[]=new byte[size];
      int length=-1;


        • 1. Re: EJB-BLOB problem.
          Andrew McCulloch Newbie

          I am fairly new at this so I may be way off but it is probably better to use the java.sql.Blob class instead of the Oracle specific BLOB object.

          Blob blob = rs.getBlob(1);

          Your class cast exception comes from the fact that the ResultSet you get back does not inherit from the Oracle version. I don't think you can use JBoss connection pooling and still use the non-standard Oracle functionality. If you need the Oracle functionality you will have to use the DriverManager.getConnection(url). Or at least that is what I have found.

          • 2. Re: EJB-BLOB problem.
            rohit Newbie

            Hello ,
            I am intending to save a blob to the table and not retrieve it.The original code saves a blob to the database.
            Blob interface which is provided by java.sql.* package doesnt have any method which returns the outputstream object.
            That is the reason why I have used BLOB of oracle.sql package.

            • 3. Re: EJB-BLOB problem.
              David Jencks Master

              BLOB blob=((OracleResultSet)(rs.getUnderlyingResultSet())).getBLOB(1);

              • 4. Re: EJB-BLOB problem.
                rohit Newbie

                I tried this code but it throws the following compilation error.
                cannot resolve symbol
                symbol : method getUnderlyingResultSet ()
                location: interface java.sql.ResultSet
                BLOB blob=((OracleResultSet)(rs.getUnderlyingResultSet())).getBLOB(1);

                Compiler tries to find the method getUnderlyingResultSet() in java.sql.ResultSet interface which it doesnt find hence the error.

                • 5. Re: EJB-BLOB problem.
                  Andrew McCulloch Newbie

                  You must cast the 'rs' object to "org.jboss.pool.jdbc.ResultSetInPool" before you can call the getUnderlyingResultSet method.

                  BLOB blob =

                  Let me know if that works as I have not tried it.

                  • 6. Re: EJB-BLOB problem.
                    David Jencks Master

                    Yes, use your imagination;-). You may also need to cast to the Oracle blob type.