Search in sources :

Example 1 with TransactionSystemException

use of com.ctrip.platform.dal.exceptions.TransactionSystemException in project dal by ctripcorp.

the class DalTransaction method cleanup.

private void cleanup(boolean commit) {
    Connection conn = connHolder.getConn();
    if (commit) {
        try {
            conn.commit();
        } catch (SQLException ex) {
            throw new TransactionSystemException("Could not commit JDBC transaction", ex);
        }
    } else {
        try {
            conn.rollback();
        } catch (SQLException ex) {
            logger.error("Could not roll back JDBC transaction", ex);
        }
    }
    try {
        conn.setAutoCommit(true);
    } catch (Throwable e) {
        logger.error("Can not setAutoCommit on current connection", e);
    }
    connHolder.close();
    DalTransactionManager.clearCurrentTransaction();
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) TransactionSystemException(com.ctrip.platform.dal.exceptions.TransactionSystemException)

Aggregations

TransactionSystemException (com.ctrip.platform.dal.exceptions.TransactionSystemException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1