I'm using this template:
try {
connection.setAutoCommit(false);
try {
// ... do something with that connection ...
connection.commit();
catch (SQLException exception) {
connection.rollback();
throw exception;
} finally {
connection.setAutoCommit(true);
}
} catch (SQLException exception) {
// log error
}
Is this the right way? How can this template be improved?