Will Druid's rollback reset connections that are set to autocommit to flase?

using the database connection pool to write code for batch operations (with transactions), always put conn.setAutoCommit (false);

first.

if there is an exception in the submitted code, conn.rollback () is executed. Do I need to set up setAutoCommit (true) again? ;

    try {
        conn = getConnection();
        conn.setAutoCommit(false);
        // 
        stmt.executeBatch();
        conn.commit();
        stmt.clearBatch();
        // 
        conn.setAutoCommit(true);
    } catch (Exception e) {
        if (conn != null) {
            conn.rollback();
        }
    } finally {
        if (conn != null) {
            // 
            conn.setAutoCommit(true);
            conn.close();
        }
}
Mar.20,2021

there is no need to set up conn.setAutoCommit (true);

conn.close();autoCommittrue.
Menu