MySQL案例04:Cause: java.sql.SQLException: Could not retrieve transaction read-only status from server
今天同事发现程序日志有异常抛出,询问原因,进过排查发现与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的更多相关文章
- 【异常】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 ...
- java.sql.SQLException: Could not retrieve transaction read-only status from server 问题解决
网上有2种主要说法 第一种 问题描述: java代码在开始事务后,先做了一个查询,再insert,此时会报: java.sql.SQLException: could not ret ...
- Cause: java.sql.SQLException: Could not retrieve transation read-only status server
背景 最近在部署一套完整的项目,部署过程中遇到很多的问题,在来总结一些如标题的这个错误! 环境说明: 使用分布式数据库,使用的是mysql! ### Cause: java.sql.SQLExcept ...
- 连接mysql数据库报错java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized...解决方法
今天连接mysql数据库报错如下: java.sql.SQLException: The server time zone value '�й���ʱ��' is unrecognized or r ...
- 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 ...
- 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 ...
- 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 ...
- 连接mysql客户端报错: java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'
报这个错可能是因为用了低版本的的客户端.驱动连接高版本的mysql服务器. 解决方式有三种:升级客户端版本.修改服务端认证方式和适应服务端认证方式. 我是通过升级客户端版本解决,参考一下链接: Upg ...
- 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 ...
随机推荐
- 如何用kindle看论文
kindle的pdf显示效果向来不好,那么如何把pdf转换成mobi格式呢 可以把个人文件(pdf)发送至您的[发送至Kindle]电子邮箱时,在电子邮件的主题栏中填写"convert&qu ...
- c# 获取程序目录
取得控制台应用程序的根目录方法1:Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径2:AppDomain.CurrentDomain.BaseDirect ...
- Python学习---PyCharm的使用学习
1.1. IDEA的使用 PyCharm2017下载 链接:https://pan.baidu.com/s/1HPR9FtVV5BCvd3uTdOetxw 密码:ok0q 激活IDEA2017(方案一 ...
- Mysql学习---索引的学习 180101
索引:约束 + 快速查找 索引是数据库中用于帮助用户快速查询数据的一种数据结构.类似于字典中的目录,查找字典内容时可以根据目录查找到数据的存放位置,然后直接获取即可. 问:为什么索引可以这么快?[类似 ...
- 计算机用CMD命令关机建立文件夹 梁华杰
1:进入CMD BJ 2:关机并取消 3:进入D盘 文件管理 创件文件并删除
- MYSQL数据库、用户、表等基础构建
MYSQL数据库.用户.表等基础构建: 1.->:创建数据库: 1.1. create schema [数据库名称] default character set utf8 collate utf ...
- Azure 登录设置
转自 http://blog.csdn.net/azure_nonofficial/article/details/38095459 这是我们Azure非官方的第一篇博文,欢迎大家各种拍砖. 微软云计 ...
- selenium+python smtp邮件
#code:utf-8 import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIM ...
- apt安装mysql
使用 APT 安装 MySQL 参考官方文档 apt-get install mysql-server 这将安装MySQL服务器的包,以及客户端和数据库公共文件的包. 在安装过程中,系统会要求您为ro ...
- LOJ #6436. 「PKUSC2018」神仙的游戏
题目分析 通过画图分析,如果存在border长度为len,则原串一定是长度为n-len的循环串. 考虑什么时候无法形成长度为len的循环串. 显然是两个不同的字符的距离为len的整数倍时,不存在这样的 ...