Subject FB Blob problem - OutOfMemory
Author phil_hhn
I've come across an issue, using FB 1.5.3.

I have a JDBC connection to a Firebird (FB) database and an SQL Server
(SS) database. I ran a query against FB, returning a Blob (in this
case originally a 20k PNG image on disk) that I want to insert into SS
(via a PreparedStatement). So I ran ResultSet.getBlob, then
PreparedStatement.setBlob. The blob (i.e the 20k PNG image) can be
retrieved from SS and viewed ok.

The problem arises when I try to run this code with lots of large
blobs (i.e several MB each) - something causes an OutOfMemory
exception (seems to be the JDBC driver).
So I changed the code to read the data from FB via an InputStream and
insert directly into SS. This does not run out of memory. I also tried
using getBytes... setBytes. In each of these the data processed (in my
small test case above) appears to be 25K, not 20k. I.e if I call
Blob.length() it returns 25k. So when I retrieve the data from SS, it
is not a valid PNG image.

I am confused - the getBlob...setBlob routines would be ideal to use
if I did not get the OutOfMemory exception, and the other code (using
streams or the low-level byte routines) appear to give spurious
results. Can anyone shed light on this problem, or suggest what the
issue might be?