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?
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:
Work with a byte-array:
byte[]
containing the data through Blob.getBytes
Blob.setBytes
.Work with InputStream
/ OutputStream
:
InputStream
through Blob.getBinaryStream
Blob.setBinaryStream
.
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.