Search code examples
javablob

How to manipulate a BLOB in Java?


I have a DB procedure which returns a BLOB. Can anyone tell me how to manipulate the BLOB? Is there any specific API for this?


Solution

  • Is there any specific API for this ?

    Sure, the JDBC API.


    You get hold of the Blob instance just as you get hold of any value from a result set. You should then use the get...- and set... methods on this Blob.

    Here you basically have two options:

    An alternative approach is to skip messing with Blob in the first place, and instead use the second approach (with streams) directly through the ResultSet-interface.