Hi,

I've just paid an attention that rollback doesn't revert changes to
database made in transaction. This is the simplified code of our
upgrade scenario:

// This line is just for showing what connection parameters we're
using:
JdbcConnectionPool pool  = JdbcConnectionPool.create("jdbc:h2:C:
\test;CIPHER=AES;LOCK_TIMEOUT=10000;AUTO_SERVER=TRUE", user, password
+ " " + password);

Connection connection = pool.getConnection();
connection.setAutoCommit(false);
try {
    Statement statement = connection.createStatement();
    try {
         statement.executeUpdate("UPDATE versions SET version='1.1';
DROP non_existent;");
    } finally {
         statement.close();
    }
    connection.commit();

} catch (SQLException e) {
    connection.rollback();
} finally {
    connection.setAutoCommit(true);
}

I intentionally wrote "DROP non_existent" to make the query fail, and
it failed indeed. But the first statement  (version increment)
succeeds, even though connection.rollback() is being called.

What am I doing wrong?

Thanks,
Michael

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to