Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> oracle.sql.BLOB.createTemporary(...) throws NullPointerException when used w/ pool
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;