Another check of the code shows that the LargeObject.write(byte[]) is
efficient with buffers since the entire buffer is being written, whereas
write(byte[] buf,int off,int len) has to create a new buffer and then copies
the data in. This is probably okay since the assumption is that you
wouldn't use the latter if you wanted to write the entire buffer, and making
a check in each call to see if (off==0 && len=buf.length) to avoid the
buffer creation and copy may be overkill.
Instead, a change to PreparedStatement.setBlob() might be able to do this
with:
if ( numRead == buf.length )
los.write(buf);
else
los.write(buf,0,numRead);
This is in the loop where the blob is being written out in 4k buffers. Note
that the call is always a zero-based buffered, and all except the "last"
write of a blob would include a full buffer. This simple test would reduce
a 4k buffer being created and copied on each los.write call except for the
last one.
Thoughts?
David