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

最近在做整合springboot的项目,但是在整合mybatis出现了下面的问题:

java.sql.SQLException: Could not retrieve transation read-only status server
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:904) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:894) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3613) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.alibaba.druid.pool.DruidConnectionHolder.(DruidConnectionHolder.java:143) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.pool.DruidConnectionHolder.(DruidConnectionHolder.java:83) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.pool.DruidDataSource.put(DruidDataSource.java:1890) ~[druid-1.0.29.jar:1.0.29]
	at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2143) [druid-1.0.29.jar:1.0.29]
Caused by: java.sql.SQLException: Unknown system variable 'tx_read_only'
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2435) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2582) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2531) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2489) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1446) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3607) ~[mysql-connector-java-5.1.35.jar:5.1.35]
	... 5 common frames omitted

2018-12-06 21:35:41.179  INFO 9611 --- [eate-2067737171] com.alibaba.druid.pool.DruidDataSource   : put physical connection to pool failed.

Process finished with exit code 130 (interrupted by signal 2: SIGINT)

这是因为我的mysql 是8.0,然后我的驱动用的是5.0的,这个时候需要修改pom.xml,添加8.0的驱动:


	mysql
	mysql-connector-java
	8.0.11

参考文献

[1].mysql 数据库8.0版本,jdbc驱动连接问题.https://www.cnblogs.com/sanduweiliangxtx/p/9219405.html

[2].解决java.sql.SQLException: Could not retrieve transation read-only status server.https://blog.csdn.net/zhbpd/article/details/38669723

你可能感兴趣的:(java,springboot,mybatis,mysql8.0)