您的位置:首页 > 编程语言 > Java开发

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

2016-11-21 18:55 543 查看
**异常摘要:**Cannot get a connection, pool error: Could not create a validated object, Could not retrieve transation read-only status server

原因: mysql 的驱动包版本的问题。

描述:

将项目移植到mysql版本为6.0的电脑上面,进行查询操作时,控制台没有报异常,然而当进行插入操作时,便出现了该异常。

上网查资料时显示,mysql 的jar 包版本太低,不支持6.0版本的数据库。上 Mysql 官网http://dev.mysql.com/downloads/connector/j/下载了对应的6.0的jar包。导入相对应的jar包后,发现问题依然存在,多方位查阅的资料显示:jar包版本不对。怀疑在官网下载的 jar 包不对,又再次下载了几个jar包,进行测试后,发现问题依然存在。

确认下载的 jar 包版本正常后,怀疑是不是多个版本 jar 包间发生了冲突。检查build path 发现jar包正常。为确保jar包正确,进入到tomcat目录中,查看引用的jar包是否正确。结果发现,引用中,果然存在多个mysql的jar包,删除非6.0 的jar包进行测试,正常插入,数据正常,问题解决!

解决方法:

(1)官网下载6.0的jar包;

(2)确保已经删除原来的jar包;

异常详细描述:

java.sql.SQLException: Could not retrieve transation read-only status server
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
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:3939)
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3910)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2410)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2377)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2361)
at zhu.com.shopping.dao.impl.OrderImpl.createOrder(OrderImpl.java:56)
at zhu.com.shopping.servlet.OrderServlet.doPost(OrderServlet.java:49)
at zhu.com.shopping.servlet.OrderServlet.doGet(OrderServlet.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at zhu.com.shopping.filter.LoginFilter.doFilter(LoginFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at zhu.com.shopping.filter.LoginFilter.doFilter(LoginFilter.java:70)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Unknown system variable 'tx_read_only'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2812)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2761)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
at com.mysql.jdbc.ConnectionImpl.isReadOnly(ConnectionImpl.java:3933)
... 27 more
status: -1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息