今天同事发现程序日志有异常抛出,询问原因,进过排查发现与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.

MySQL案例04:Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server的更多相关文章

  1. 【异常】java.sql.SQLException: Could not retrieve transaction read-only status from server Query

    1 详细异常 java.sql.SQLException: Could not retrieve transaction read-only status , ], [ChargingOrderRea ...

  2. java.sql.SQLException: Could not retrieve transaction read-only status from server 问题解决

    网上有2种主要说法 第一种 问题描述: java代码在开始事务后,先做了一个查询,再insert,此时会报:          java.sql.SQLException: could not ret ...

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

    背景 最近在部署一套完整的项目,部署过程中遇到很多的问题,在来总结一些如标题的这个错误! 环境说明: 使用分布式数据库,使用的是mysql! ### Cause: java.sql.SQLExcept ...

  4. 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized...解决方法

    今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or r ...

  5. Eclipse使用jdbc连接MySql数据库报:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

    在使用eclipse连接mysql数据库时报异常: java.sql.SQLException: Access denied for user 'root'@'localhost' (using pa ...

  6. MySql中报错:java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xBB' for column

    问题描述: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xBB' for column 'nickName' at row ...

  7. mysql报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

    mybatis链接mysql,启动服务报错: java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecogni ...

  8. 连接mysql客户端报错: java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'

    报这个错可能是因为用了低版本的的客户端.驱动连接高版本的mysql服务器. 解决方式有三种:升级客户端版本.修改服务端认证方式和适应服务端认证方式. 我是通过升级客户端版本解决,参考一下链接: Upg ...

  9. mysql报错:java.sql.SQLException: Incorrect string value: '\xE4\xB8\x80\xE6\xAC\xA1...' for column 'excelName' at row 1

    一.问题 用Eclipse做项目时候报错 java.sql.SQLException: Incorrect string value: '\xE4\xB8\x80\xE6\xAC\xA1...' fo ...

随机推荐

  1. 颤振错误:当前Flutter SDK版本为2.1.0-dev.0.0.flutter-be6309690f?

    我刚刚升级了我的扑动,升级后我无法在Android Studio上运行任何扑动项目.我收到此错误消息. The current Dart SDK version -dev.0.0.flutter-be ...

  2. VUE知识day3_vue插件总结

  3. leetcode Ch3-DFS & Backtracking II

    一.Gray Code class Solution { public: vector<int> grayCode(int n) { vector<}; ) return resul ...

  4. 倒计时特效的CountAnimationLabel

    倒计时特效的CountAnimationLabel 效果: 源码: CountAnimationLabel.h 与 CountAnimationLabel.m // // CountAnimation ...

  5. Django路由系统---django重点之url映射分发

    django重点之url映射分发 在全局项目的urls.py中进行子项目的映射,然后在子项目中创建一个urls.py去处理自己项目中的请求,同时也实现了代码的解耦 添加路由分发的原则[全局urls.p ...

  6. Java学习---传输安全设计

    1.计算机安全的概念 用于保护数据和阻止Hacker的工具统称为计算机安全(Computer Security).信息安全最基本的方法就是利用加密信息防止未授权的人窃听,加密是以某种特殊的算法改变原有 ...

  7. Eclipse导出可运行的jar包并运行

    https://blog.csdn.net/kpchen_0508/article/details/49275407 程序运行的第二种方式:

  8. MQ环境的搭建

    MQ环境的搭建

  9. Java日期格式化参数对照表

    Symbol Meaning Presentation Example G era designator Text AD y year Number 2009 M month in year Text ...

  10. JS实现图片上传之前先预览

    <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat=&quo ...