conn.setAutoCommit(false);
// Set a conservative transaction isolation level.
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
Statement stmt = conn.createStatement();
int rows = stmt.executeUpdate( "INSERT INTO authors " + " (first_name, last_name) VALUES " + " ('Ghq', 'Wxl')"); // Set a named savepoint.
Savepoint svpt = conn.setSavepoint("NewAuthor"); // …
rows = stmt.executeUpdate( "UPDATE authors set type = 'fiction' " + "WHERE last_name = 'Wxl'"); // …
conn.rollback(svpt); // … // The author has been added, but not updated.
conn.commit();