Subject Re: [Firebird-Java] Insert StringBuffer into BLOB SUB_TYPE 1
Author Thomas Steinmaurer
Hello Roman,

>> is it safe to insert a largish (possibly > 1MB) amount of data from a
>> StringBuffer into a BLOB SUB_TYPE 1 field by using the following?
>>
>> ps.setString(2, xml.toString());
>>
>> where ps is a PreparedStatement and xml is a StringBuffer? Or do I have
>> to use some kind of streaming?
>
> No, it is enough to use setString() method. The only consequence is that
> data will be kept in memory before the executeUpdate is issued. When you
> use streams (InputStream) in non-autocommit mode, it will create BLOB,
> pump data into database and keep in memory only the BLOB ID. But
> nowadays 1 MB is not that much, so feel free to use setString.

I'm using executeUpdate() immediately after all parameters are set.

Thanks for the pointer regarding memory usage with setString() vs.
streams. I keep this in mind in case I want to store larger text data in
a BLOB field, especially because this happens in a multi-threaded socket
server handling several TCP client connections and receiving data from
them, which needs to be stored in the database.

Thanks,
Thomas