mysql tx read only_MySql关于java.sql.SQLException: Unknown system variable 'tx_read_only'

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException:

### Error updating database. Cause: java.sql.SQLException: Could not retrieve transation read-only status server

### The error may involve org.leon.mybatis.mapper.UserMapper.save-Inline

### The error occurred while setting parameters

### SQL: INSERT INTO mybatis_user(name,sex,age) VALUES(?,?,?)

### Cause: java.sql.SQLException: Could not retrieve transation read-only status server

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200)

at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)

at org.leon.mybatis.test.MyBatisTest.main(MyBatisTest.java:24)

Caused by: java.sql.SQLException: Could not retrieve transation read-only status server

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:951)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:941)

at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3972)

at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3943)

at com.mysql.jdbc.PreparedStatement.checkReadOnlySafeStatement(PreparedStatement.java:1258)

at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1278)

at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)

at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)

at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)

at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)

at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)

at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)

... 2 more

Caused by: java.sql.SQLException: Unknown system variable 'tx_read_only'

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1086)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2828)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2777)

at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1651)

at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3966)

... 11 more

Process finished with exit code 1

关于使用MySql 和MyBatis时console显示如下异常:

java.sql.SQLException: Unknown system variable 'tx_read_only'

原因:Mysql与MyBatis版本不匹配。

解决方法:升级MySql或者使用低版本的MyBaits Jar包。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值
>