今日朋友发觉程序流程系统日志有出现异常抛出去,了解缘故,进过清查发觉与java的联接主要参数有关系,实际处理方式以下:

一、错误报告

"message": "\n### Error updating database. Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server\n### The error may involve com.longfor.io.sync.mapper.IoSyncMapper.insert-Inline\n### The error occurred while setting parameters\n### 
SQL: INSERT INTO io_xxx ( io_id, sync_batch, sync_status, data_start_date, data_end_date ) VALUES ( ?, ?, ?, ?, ? )\n###
Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server\n; SQL [];
Could not retrieve transaction read-only status from server; nested exception is java.sql.SQLException: Could not retrieve transaction read-only status from server",

二、不正确缘故

数据库查询版本是5.7.18-log,而程序流程mysql-connector 库应用的版本是5.1.43,这儿用全新的mysql-connector-java-5.1.46-bin.jar更换掉mysql-connector-java-5.1.43-bin.jar

三、解决方法

1.免费下载全新的mysql-connector-java库,更换重新启动

https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.11-1.el6.noarch.rpm

https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.46.tar.gz

用全新的mysql-connector-java-5.1.46-bin.jar更换掉mysql-connector-java-5.1.43-bin.jar

goole客户解决方法:
老库是 mysql-connector-java-5.1.24-bin.jar 这一用在 mysql 5.6.19 版本没有问题,可是在 mysql 5.6.20 版本行就汇报上边的出现异常。应用全新的 mysql-connector-java-5.1.32-bin.jar 后难题状况清除。

2.google发觉有说在jdbc配备中立即改动掉useServerPrepStmts=false主要参数

https://stackoverflow.com/questions/32717417/sqlexception-could-not-retrieve-transation-read-only-status-server

Finaly, I found the root cause of my problem. This is not the database inside the URL, just a consequence.

The problem come from JDBC parameters I use :

cachePrepStmts=true
prepStmtCacheSize=250
prepStmtCacheSqlLimit=2048
useServerPrepStmts=true
The last one, with MySQL 5.6 is really not recommended because of bugs. So I have remove all statement cache parameters and now my code run correctly.