I tried to insert a LOB - a 4000 long
String converted to bytearray into a BLOB column of Oracle.
code is like this:
conn.setAutoCommit(false);
qry = "select blobby from temp for update";
pstt = conn.prepareStatement(qry);
ResultSet rs = pstt.executeQuery();
rs.next();
oracle.sql.BLOB BL1 =
(oracle.sql.BLOB) rs.getBlob(1);
java.io.OutputStream opStream =
BL1.getBinaryOutputStream();
for(int i=0; i<bytearray.length;i++)
{
opStream.write(bytearray[i]);
}
// I tried this too :
// opStream.write(bytearray);
qry = "insert into temp(blobby)values(?)";
pstt = conn.prepareStatement(qry);
pstt.setBlob(1,BL1);
The String is like : "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ ......"
But when BL1 was checked(using getBytes()) the value is like :
" T ☺☺♀ ☺ ☺ ☻☻D ?u ?t ☺ ☺ ←?tr♂?tr♂ ☺♂0? ....."
Whatever the original length the BL1 length is 86
What is the correct way of inerting a LOB into a BLOB column ?
Thanks