解决Mysql事务异常

在使用事务进行Mysql操作时,会抛出异常信息:

 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. 
 InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.
java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. 
InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.

异常信息提示的比较明确,是事务隔离界别与Mysql的binlog类型不符合。

  1. 查询Mysql版本,SELECT VERSION()结果为5.5.35
  2. 查询binlog类型,select @@binlog_format结果为STATEMENT
  3. 查看数据库连接池参数配置中,defaultTransactionIsolation=READ_COMMITTED

由此得出,当事务隔离界别为read-commited时,不支持STATEMENT的binlog类型

解决方案

1.修改Mysql服务器的binlog类型为ROW或者MIXED
2.修改连接池参数中事务隔离级别为REPEATABLE-READ

关于binlog类型以及事务隔离级别请参考之前的文章

转载于:https://my.oschina.net/u/1161660/blog/3010852

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值