Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> oracle.sql.BLOB.createTemporary(...) throws NullPointerException when used w/ pool

oracle.sql.BLOB.createTemporary(...) throws NullPointerException when used w/ pool

From: Bomb Diggy <techguy_chicago_at_yahoo.com>
Date: 8 Aug 2003 17:11:00 -0700
Message-ID: <94599bb3.0308081611.656a638b@posting.google.com>


I copied some createTemporaryCLOB code from the technet.oracle.com site, hacked it to work for BLOB types instead of CLOBs, then started using it in standalone Java programs.

But now I want to use it in a J2EE environment - specifically from a servlet. When attempting to do so, however, the call to
'createTemporaryBlob()' blows up with a NullPointerException. Any
ideas?

I'm using, via my WSAD setup, the
oracle.jdbc.pool.OracleConnectionPoolDataSource for my pool
'implementation class'.

My other params are valid, non-null, etc. I figure no method should ever throw an NPE... I am only importing oracle.sql.Blob, so there's no chance I'm blowing up on trying to execute a method on the null java.sql.Blob reference.

I'm using Oracle Client version 9.2.0 and the classes12.jar it ships with. Same version for the server.

The reason I've gone the route of using the Oracle BLOB type is b/c I need to store large BLOB files into one of my tables via a stored procedure - and the [CallableStatement].setBinaryStream(...) doesn't work past 32K.

Thanks for any help!

private static BLOB getBLOB( Connection conn, byte[] blobData ) throws Exception
{
  BLOB tempBlob = null;
  try {

     // next line blows up!  NullPointerException!
     tempBlob = createTemporary( conn, true, BLOB.DURATION_SESSION );
     tempBlob.open( BLOB.MODE_READWRITE );
     OutputStream outstream =
((BLOB)tempBlob).getBinaryOutputStream();
     outstream.write(blobData);
     outstream.flush();
     outstream.close();
     tempBlob.close();
  } catch ( Exception exp ) {
      tempBlob.freeTemporary( );
      throw exp;

  }
  return tempBlob;
} Received on Fri Aug 08 2003 - 19:11:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US