鍍金池/ 問答/Java  數(shù)據(jù)庫(kù)  網(wǎng)絡(luò)安全/ Mysql不支持JDBC的autoCommit事務(wù)操作嗎?

Mysql不支持JDBC的autoCommit事務(wù)操作嗎?

下面是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
     */
回答
編輯回答
雨蝶

你的Mysql表類型是 innodb 還時(shí) myisam 后者是不支持事務(wù)的

2017年4月13日 14:58