I have read through several websites that showing the sample code to convert java.sql.Blob
object to byte[]
and finally saved as a file.
e.g. easiest-way-to-convert-a-blob-into-a-byte-array or image-to-bytearray-to-blob-and-blob-to-bytearray-to-image-conversion-issues-in-j
Most of the suggestion use blob.getBytes(pos, length)
i.e.
byte[] blobBytes = blob.getBytes(1, (int) blob.length());
However if the size of the blob more than the maximum value of integer(e.g. 3 GB), the blobBytes
object will be truncated and the created file will be malformed
Is there anyway to overcome the size limitation of that?
or is it I have to use blob.getBinaryStream(1, blob.length())
to get InputStream and further process it to byte[]?