Java.sql.SQLException:Can't call commit when Autocommit=true at Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:934) at Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:931) at Com.mysql.jdbc.ConnectionImpl.commit (Connectionimpl.java:1646)
Today, when using Hibernate, the error is reported!
The reason for surfing the internet is because hibernate is used, commit () or rollback (), both of which require a prerequisite, that is, MySQL Auto-submit function to be closed.
Commit () is committed by committing the last commit or rollback of the modified content, and releasing the relevant content in the connection.
The role of rollback () is to rollback to the content of the last commit or rollback.
The above two methods can only be used in modes that have auto-commit disabled.
Therefore, turning off MySQL auto-commit is possible.
In the MySQL client:
MySQL>Select@ @autocommit;
Check to see if auto-commit is turned on, and if 1, it turns on. If it is 0, it indicates off .
You can close it in the following way.
MySQL>set autocommit=0;
"Mysql"--Error: Can ' t call commit when autocommit=true