Need help saving BLOBs to file from Oracle 8.0.5 database
Date: 27 Mar 2002 17:46:01 -0800
Message-ID: <bba951b5.0203271746.214e1c09_at_posting.google.com>
Following code to extract BLOBs from Oracle 8.0.5 DB to files work fine except for smaller files. It doesn't extract small files (approx. less than 4k).
I am using JDBC OCI drivers.
What am I missing?
BLOB blob = ((OracleResultSet)rs).getBLOB("LOBLOC");
FileOutputStream out = new FileOutputStream(outFile); InputStream in = blob.getBinaryStream();
int chunk = blob.getChunkSize();
byte[] buffer = new byte[chunk];
int length = -1;
int count = 0;
long bytesWritten = 0;
// for smaller files, in.read(buffer) below returns -1 ... not sure
why !
while ((length = in.read(buffer)) != -1)
{
count++;
if ( count % 1 == 0 )
{
}
bytesWritten += length;
out.write(buffer, 0, length);
}
in.close();
out.close();
Thanks for any help. Received on Thu Mar 28 2002 - 02:46:01 CET