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 ...
随机推荐
- java笔记--正则表达式的运用(包括电话,邮箱验证等)
正则表达式 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XHJT/p/3877402.html "谢谢-- 正则表达式符号:" ...
- poj 1475 推箱子
bfs是一层层的遍历下去,每多一层即为多走一步,因此只要遇到T就停,此时肯定是最小步数. 所以这两层bfs应为,先对箱子的最少步数进行bfs,从而求出推箱子所用最少步数: 然后箱子bfs内部嵌入人的b ...
- socket概念 套接字
理解socket soxket因为TCP是面向流的,你发的信息如果很多很快,TCP这样就会形成黏包 Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口.在设计模式中,Socke ...
- 用POP动画编写带富文本的自定义动画效果
用POP动画编写带富文本的自定义动画效果 [源码] https://github.com/YouXianMing/UI-Component-Collection [效果] [特点] * 支持富文本 * ...
- 快速设置UITableView不同section对应于不同种类的cell
快速设置UITableView不同section对应于不同种类的cell 本文主要是为了写明如何在UITableView中,一个section对应于一种类型的cell,写起来不凌乱. 在不封装任何类的 ...
- Python学习---django下的cookie操作 180201
什么是Cookies 什么是Cookies cookies设置的原因: 1. http请求的无记忆性: 2.加快访问速度 3. 减少服务器压力 cookies特点: cookies保存在客户端浏览器 ...
- TMG 2010 为HTTPS协议添加非标准端口(443)
1.添加加密端口时,编辑脚本addsslports.vbs addsslports.vbs 脚本内容如下: Dim root Dim tpRanges Dim newRange Set root = ...
- 计算机应用基础教程作业flash动画 车辆工程 冯大昕
- December 20th 2016 Week 52nd Tuesday
With the wonder of your love, the sun above always shines. 拥有你美丽的爱情,太阳就永远明媚. To accept the love from ...
- [EffectiveC++]item41:了解隐式接口和编译期多态