MySQL错误: could not retrieve transation read-only status server

Posted kika

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL错误: could not retrieve transation read-only status server相关的知识,希望对你有一定的参考价值。

问题描述: java代码在开始事务后,先做了一个查询,再insert,此时会报: 
        java.sql.SQLException: could not retrieve transation read-only status server
 

解决过程: 

        查看mysql的事物隔离级别 SHOW VARIABLES LIKE ‘%iso%‘;

        返回结果: REPEATABLE-READ

 

        把这个改成:READ-COMMITTED 就好了: SET GLOBAL tx_isolation=‘READ-COMMITTED‘; 

 (记得java重启应用,要永久生效的就改my.ini配置文件)

 

问题分析:

        当数据库隔离级别为REPEATABLE-READ时,查询一个select语句也算是事物的开始,而且在hibernate里会把以select语句开头的事务标记为只读事务,此时在这个事务里再执行insert、update、delete等DML语句就会报错。

 

http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_tx_read_only

以上是关于MySQL错误: could not retrieve transation read-only status server的主要内容,如果未能解决你的问题,请参考以下文章

MySQL错误: could not retrieve transation read-only status server

pip ERROR: Could not find a version that satisfies the requirement loguru (from versions: none)

Mysql主从错误:could not find first log file name in binary....

连接MySQL错误“plugin caching_sha2_password could not be loaded”的解决办法

问题汇总记录----mysql不能启动,提示service could not be started

mysql could not be resolved: Name or service not known