I got the BLOB data from the database and use the below code to put it into a string(rs is the ResultSet, file is a Map), is there a way to put this string value back to the BLOB columns?
Blob blob = rs.getBlob("FILE_DATA");
if(blob != null) {
byte[] bdata = blob.getBytes(1, (int) blob.length());
String data = new String(bdata);
file.put("FILE_DATA", data);
}
I have tried some suggestions like this one, but they don't work well.
Blob blbVal = getConnection().createBlob();
byte[] fileData = value.toString().getBytes();
blbVal.setBytes(1, fileData);
cs.setBlob(index, blbVal);