Path: newssvr20.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!pd2nf1so.cg.shawcable.net!residential.shaw.ca!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: techguy_chicago@yahoo.com (Bomb Diggy)
Newsgroups: comp.databases.oracle.server
Subject: oracle.sql.BLOB.createTemporary(...) throws NullPointerException when used w/ pool
Date: 8 Aug 2003 17:11:00 -0700
Organization: http://groups.google.com/
Lines: 49
Message-ID: <94599bb3.0308081611.656a638b@posting.google.com>
NNTP-Posting-Host: 192.35.35.35
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1060387861 27503 127.0.0.1 (9 Aug 2003 00:11:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 9 Aug 2003 00:11:01 GMT
Xref: newssvr20.news.prodigy.com comp.databases.oracle.server:240147

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;
}
