I have a data type that is stored as blob (XML) in Oracle DB. I am extracting this column and converting it to byte [] and then to string. I perform some string operations and convert them to UTF-8 format and insert them back into the database. Some special characters are inserted as unwanted characters. I don’t know what am I doing wrong? Any idea / help would be greatly appreciated.
Here is the source code.
Blob data = (Blob) rs.getBlob(3);
byte[] bdata = data.getBytes(1,(int)data.length());
s = new String(bdata);
byte[] dataAsByteArray = s.getBytes("UTF8");
updateStmt.setBinaryStream(1,
new ByteArrayInputStream(dataAsByteArray),dataAsByteArray.length);
commit();
source
share