I have datatype stored as blob (XML) in Oracle DB. I am retrieving this column and converting to byte[] and then to string. I do some string operations and converting it to UTF-8 format and inserting back into the DB. Some special characters are inserted as junk characters. I do not really know what I am doing wrong? Any idea/ help would be highly appreciated.
Here is the source code.
// DB COnnection
// Get the resultset
Blob data = (Blob) rs.getBlob(3);
byte[] bdata = data.getBytes(1,(int)data.length());
// Converting to String and doing operation
s = new String(bdata);
// String operation
// Before inserting into DB, converting to UTF-8 format.
byte[] dataAsByteArray = s.getBytes("UTF8");
updateStmt.setBinaryStream(1,
new ByteArrayInputStream(dataAsByteArray),dataAsByteArray.length);
commit();