This content has been marked as final. Show 3 replies
First of all; Blob (Binary large object) is a collection of binary data stored as a single entity in the database. Basically Byte array in the database... So, I am not sure what do you mean with "encoding", if you mean "character encoding", you shouldn't care about it since it is binary data and you do not want to convert it to String.
And here is the code snippet that retrieves BLOG field to Byte array in Java
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
... PREPARE THE QUERY ...
result = stmt.executeQuery();
Blob blob = result.getBlob("BLOB_FIELD_NAME");
InputStream inputStream = blob.getBinaryStream();
while ((Size = inputStream.read()) != -1)
returnBytes = byteArrayOutputStream.toByteArray();
Thanks for your reply.
Actually I want the byte array to be converted into a word document.
i.e. A Microsoft Word Document was stored in Blob field. I need to get that and combine into a big master document with some other data. So I need the word document in the way as it was before storage.
Now, I am able to retrieve the Blob data, but its binary format. I need the clear text to display. I tried converting a byte array to String using encodings, but its the same.
Any help would be great.
You have to use MS Office API to access/modify word document.