歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Java 默認事務級別read committed對binlog_format的需求

Java 默認事務級別read committed對binlog_format的需求

日期:2017/3/1 9:46:02   编辑:Linux編程

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.

tomcat拋異常如上!

提示是事務級別在read committed和read uncommitted的時候

binlog必須設置為row格式

這個是java設置的一個局限性,java默認的事務級別是read committed,而mysql默認設置的binlog_format=statement。

將binlog_format設置為mixed

set global binlog_format=mixed;

過段時間,異常仍在!

設置成row

set global binlog_format=row;

問題解決!

或:

mysql> SET SESSION binlog_format = 'ROW';

mysql> SET GLOBAL binlog_format = 'ROW';

注意: 若手動修改linux下面/etc/my.cnf : binlog_format = row , 需要在重啟mysql是注意配置是否生效,本人測試比較難生效。

Copyright © Linux教程網 All Rights Reserved