PreparedStatement pstmt = con.prepareStatement("INSERT INTO testblob(id, lo) VALUES(?,?)");
byte [] initialData = randomData();
pstmt.setString(1,"testConcurrentReplace");
pstmt.setObject(2, new SerialBlob(initialData), Types.BLOB);
assertEquals(1, pstmt.executeUpdate());
con.commit();
con2.rollback();
// con2 access the blob
PreparedStatement pstmt2 = con2.prepareStatement("SELECT lo FROM testblob WHERE id=?");
pstmt2.setString(1, "testConcurrentReplace");
ResultSet rs2 = pstmt2.executeQuery();
assertTrue(rs2.next());
// con replace the blob
byte [] newData = randomData();
pstmt = con.prepareStatement("UPDATE testblob SET lo=? where id=?");
pstmt.setObject(1, new SerialBlob(newData), Types.BLOB);
pstmt.setString(2,"testConcurrentReplace");
assertEquals(1, pstmt.executeUpdate());
// con2 read the blob content
Blob initContentBlob = rs2.getBlob(1);