问题描述
- myeclipse链接mysql数据库报错
-
Unknown system variable 'tx_read_only'
Could not retrieve transation read-only status server
--- The error occurred in sqlmaps/user/userSQL.xml. --- The error occurred while applying a parameter map. --- Check the user.login-InlineParameterMap. --- Check the statement (query failed). --- Cause: java.sql.SQLException: Could not retrieve transation read-only status server
SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S1000]; error code [0]; --- The error occurred in sqlmaps/user/userSQL.xml. --- The error occurred while applying a parameter map. --- Check the user.login-InlineParameterMap. --- Check the statement (query failed). --- Cause: java.sql.SQLException: Could not retrieve transation read-only status server; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occurred in sqlmaps/user/userSQL.xml. --- The error occurred while applying a parameter map. --- Check the user.login-InlineParameterMap. --- Check the statement (query failed). --- Cause: java.sql.SQLException: Could not retrieve transation read-only status server
解决方案
当数据库隔离级别为REPEATABLE-READ时,发布一个select语句也算是事物的开始,而且在hibernate里会把以select语句开头的事务标记为只读事务,此时在这个事务里再执行insert、update、delete等DML语句就会报错;
解决办法:修改事务类型;
如果没有用框架,在数据库执行 SET GLOBAL tx_isolation='READ-COMMITTED';
如果使用框架,如Hibernate,可是使用配置。
解决方案二:
你这个的事务没有配好,select是只读的事务,其他的不是
时间: 2024-10-28 09:01:04