java - 关闭数据库连接之前为什么要先设置自动提交为true?
伊谢尔伦
伊谢尔伦 2017-04-18 10:06:03
0
1
821
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回覆(1)
左手右手慢动作

    protected void resetAutoCommit() {
        try {
          if (!connection.getAutoCommit()) {
            // MyBatis does not call commit/rollback on a connection if just selects were performed.
            // Some databases start transactions with select statements
            // and they mandate a commit/rollback before closing the connection.
            // A workaround is setting the autocommit to true before closing the connection.
            // Sybase throws an exception here.
            if (log.isDebugEnabled()) {
              log.debug("Resetting autocommit to true on JDBC Connection [" + connection + "]");
            }
            connection.setAutoCommit(true);
          }
        } catch (SQLException e) {
          log.debug("Error resetting autocommit to true "
              + "before closing the connection.  Cause: " + e);
        }
      }

程式碼中已經明確的說明了。那段註釋。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板