"Mysql"--Error: Can ' t call commit when autocommit=true

Source: Internet
Author: User
Tags mysql client

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.