wood burning stoves*
The moose likes JDBC and the fly likes Appending to a Blob Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Appending to a Blob" Watch "Appending to a Blob" New topic
Author

Appending to a Blob

Dallas Wrege
Greenhorn

Joined: Jan 07, 2013
Posts: 1
Hey gang -

I have a large Blob object, and I would like to append to it rather than rewrite it. The following code works for Oracle (10.2) but not with MySQL (5.5). It works on a sample table called TEST_BLOB with a long primary key (UNIQUEID) and a blob (DETAILS):

Thoughts?

Thanks in advance,
Dallas
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Welcome to the Ranch!

First of all, how does the code fail in MySQL? Just saying "it does not work" is not very useful.

I don't use MySQL myself, but what I've found by googling mysql append to blob seems to suggest you need to use the CONCAT function in MySQL to add to a BLOB.

Also, this page says:
The BLOB implementation does not allow in-place modification (they are copies, as reported by the DatabaseMetaData.locatorsUpdateCopies() method). Because of this, use the corresponding PreparedStatement.setBlob() or ResultSet.updateBlob() (in the case of updatable result sets) methods to save changes back to the database.

I'm afraid that might mean that appending to an existing blob is not supported by Connector/J.
Bernd Eckenfels
Greenhorn

Joined: Sep 06, 2013
Posts: 2
Dallas Wrege wrote:Hey gang -
I have a large Blob object, and I would like to append to it rather than rewrite it.
...


I had a similiar problem, and at least for Derby it works if I add

Greetings
Bernd
 
jQuery in Action, 2nd edition
 
subject: Appending to a Blob
 
Similar Threads
2 conditions to be checked
how to create BLOB and CLOB data
Data lost when writing object to a file
fetch out of sequence
Downloading file from Oracle DB