public void testSetString() throws Exception {
  connection.setAutoCommit(false);
  PreparedStatement stmt=connection.prepareStatement("INSERT INTO test_blob(id, bin_data) VALUES(?, ?)");
  try {
    stmt.setInt(1,1);
    stmt.setString(2,TEST_TEXT);
    stmt.executeUpdate();
    connection.commit();
    stmt.setInt(1,2);
    stmt.setString(2,TEST_TEXT);
    stmt.executeUpdate();
    connection.commit();
    stmt.setInt(1,3);
    stmt.setString(2,TEST_TEXT);
    stmt.executeUpdate();
    connection.commit();
  }
  finally {
    stmt.close();
  }
  connection.setAutoCommit(true);
}

public void testSetString ( ) throws Exception { connection . setAutoCommit ( false ) ; PreparedStatement stmt = connection . prepareStatement ( "INSERT INTO test_blob(id, bin_data) VALUES(?, ?)" ) ; try { stmt . setInt ( 1 , 1 ) ; stmt . setString ( 2 , TEST_TEXT ) ; stmt . executeUpdate ( ) ; connection . commit ( ) ; stmt . setInt ( 1 , 2 ) ; stmt . setString ( 2 , TEST_TEXT ) ; stmt . executeUpdate ( ) ; connection . commit ( ) ; stmt . setInt ( 1 , 3 ) ; stmt . setString ( 2 , TEST_TEXT ) ; stmt . executeUpdate ( ) ; connection . commit ( ) ; } finally { stmt . close ( ) ; } connection . setAutoCommit ( true ) ; }
this test initially was created to find the bug when longvarchar column is used , but it revealed the bug with blobs . we try to execute some blob updates one by one in non - autocommit mode . this tests if transaction is started before the blob is created .
