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 ...
随机推荐
- ORACLE数据仓库学习记录
一.数据仓库安装 安装ORACLE DATABASE 10g Release 2 ORACLE数据库版本是:10.2.0.1.0(服务器).执行基本安装(安装全部的组件)并创建示例数据库. 安装ORA ...
- PHP array_flip() array_merge() array+array的使用总结
array_flip(array); //传递一个数组参数,对该数组的键.值进行翻转 例如: $a = array( 'a', 'b', 'c' ); print_r(array_flip($a)); ...
- 简析 Tomcat 、Nginx 与 Apache 的区别
简析 Tomcat .Nginx 与 Apache 的区别 本文讲的是简析 Tomcat .Nginx 与Apache的区别, 经常在用 apache 和 tomcat 等这些服务器,可是总感觉还是不 ...
- 移动 App 接入 QQ 登录/分享 图文教程
移动 App 接入 QQ 登录/分享 图文教程 这里先要提两个平台,腾讯开放平台和 QQ 互联平台: (一)腾讯开放平台 官网地址:https://open.tencent.com/ 介绍:腾讯开放平 ...
- 理解 on-policy 和 off-policy
转自:https://www.cnblogs.com/xiachongkun/p/7767976.html,感谢分享 大名鼎鼎的蒙特卡洛方法(MC),源自于一个赌城的名字,作为一种计算方法,应用领域众 ...
- centos安装flash
自己操作步骤: 1 :http://get.adobe.com/cn/flashplayer/ 还是进入此下载页选择“.rpm,适用于其它Linux”,下载该rpm文件 2 :# rpm -iv ...
- sql随机时间
declare @endtime datetime declare @starttime datetime set @starttime='2017-09-01' set @endtime = '20 ...
- 一些baidu面经
百度问的一些问题供参考: 1. epoll 和 select,epoll 两种模式,阻塞非阻塞: 2. 两个严格递增链表找出相同的元素组成新的链表: ref1 ref 3. 网络传输中如何传送一个 ...
- PL/SQL编程基础——PL/SQL简介
课程教师:李兴华 课程学习者:阳光罗诺 日期:2018-07-28 知识点: 1. 了解PL/SQL的主要特点 2. 掌握PL/SQL块的基本结构 PL/SQL PL/SQL是Oracle在关系数据库 ...
- DAO,SERVICE