반응형
http://java.sun.com/developer/EJTechTips/2005/tt0125.html#1
try {
Connection con = makeDatabaseConnection();
con.setAutoCommit(false);
// Do whatever database transaction functionality
// is necessary
con.commit();
} catch (Exception ex) {
try {
con.rollback();
} catch (SQLException sqx) {
throw new EJBException("Rollback failed: " +
sqx.getMessage());
}
} finally {
releaseDatabaseConnection();
}
try {
Connection con = makeDatabaseConnection();
con.setAutoCommit(false);
// Do whatever database transaction functionality
// is necessary
con.commit();
} catch (Exception ex) {
try {
con.rollback();
} catch (SQLException sqx) {
throw new EJBException("Rollback failed: " +
sqx.getMessage());
}
} finally {
releaseDatabaseConnection();
}