Mysql不支持JDBC的autoCommit事务操作吗?

下面是com.mysql.jdbc.ConnectionImpl类的setAutoCommit(boolean flag)方法的注释

最后一句,Note: MySQL does not support transactions, so this method is a
no-op.

/**
     * If a connection is in auto-commit mode, than all its SQL statements will
     * be executed and committed as individual transactions. Otherwise, its SQL
     * statements are grouped into transactions that are terminated by either
     * commit() or rollback(). By default, new connections are in auto- commit
     * mode. The commit occurs when the statement completes or the next execute
     * occurs, whichever comes first. In the case of statements returning a
     * ResultSet, the statement completes when the last row of the ResultSet has
     * been retrieved or the ResultSet has been closed. In advanced cases, a
     * single statement may return multiple results as well as output parameter
     * values. Here the commit occurs when all results and output param values
     * have been retrieved.
     * <p>
     * <b>Note:</b> MySQL does not support transactions, so this method is a
     * no-op.
     * </p>
     * 
     * @param autoCommitFlag -
     *            true enables auto-commit; false disables it
     * @exception SQLException
     *                if a database access error occurs
     */
阅读 4.1k
1 个回答

你的Mysql表类型是 innodb 还时 myisam 后者是不支持事务的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题