java com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:autocommit=true 时无法调用回滚

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3911968/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 03:56:32  来源:igfitidea点击:

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Can't call rollback when autocommit=true

javamysqljdbcjboss

提问by Tamizh

Im using Jboss5.0 with mysql in my application. and there will be lot of concurrent actions and DB contains considerably lot of records. this error is coming frequently.. every now and then.

我在我的应用程序中使用 Jboss5.0 和 mysql。并且会有很多并发操作,DB 包含相当多的记录。这个错误经常出现.. 时不时。

 com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException:
 Can't call rollback when
 autocommit=true    at
 com.mysql.jdbc.SQLError.createSQLException(SQLError.java:888)
    at
 com.mysql.jdbc.Connection.rollback(Connection.java:5192)
    at
 org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.rollback(LocalManagedConnection.java:97)
    at
 org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.tidyup(TxConnectionManager.java:783)
    at
 org.jboss.resource.connectionmanager.BaseConnectionManager2.returnManagedConnection(BaseConnectionManager2.java:453)
    at
 org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:734)
    at
 org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:362)
    at
 org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:155)

can anyone help?

有人可以帮忙吗?

Thanks in advance

提前致谢

回答by Cyntech

Either you are attempting to call rollback when auto commit is turned on, or you're using MyISAM type tables in your database which do not support transactions (and the ability to rollback).

要么您尝试在打开自动提交时调用回滚,要么您在数据库中使用不支持事务(以及回滚能力)的 MyISAM 类型表。

Judging by the stacktrace, a transaction to the database is failing and in an attempt to create an SQLException and rollback the transaction, this exception is occurring. Unless there's more to the exception (like an indication as to where in yourcode the exception is being fired), then I would hazard a guess that it's due to MyISAM tables.

根据堆栈跟踪判断,对数据库的事务失败并且在尝试创建 SQLException 并回滚事务时,正在发生此异常。除非有更多的除外(例如指示在何处在你的代码中的异常被解雇),那么我会大胆地猜测,这是由于MyISAM表。