Connection is read-only. Queries leading to data modification are not allowed
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
private synchronized void switchCurrentConnectionTo(int hostIndex, MySQLConnection connection) throws SQLException { invalidateCurrentConnection(); boolean readOnly; if (isPrimaryHostIndex(hostIndex)) { readOnly = this.explicitlyReadOnly == null ? false : this.explicitlyReadOnly; } else if (this.failoverReadOnly) { readOnly = true; } else if (this.explicitlyReadOnly != null) { readOnly = this.explicitlyReadOnly; } else if (this.currentConnection != null) { readOnly = this.currentConnection.isReadOnly(); } else { readOnly = false; } syncSessionState(this.currentConnection, connection, readOnly); this.currentConnection = connection; this.currentHostIndex = hostIndex;} |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
protected int executeUpdate(byte[][] batchedParameterStrings, InputStream[] batchedParameterStreams, boolean[] batchedIsStream, int[] batchedStreamLengths, boolean[] batchedIsNull, boolean isReallyBatch) throws SQLException { synchronized (checkClosed().getConnectionMutex()) { MySQLConnection locallyScopedConn = this.connection; if (locallyScopedConn.isReadOnly()) { throw SQLError.createSQLException(Messages.getString("PreparedStatement.34") + Messages.getString("PreparedStatement.35"), SQLError.SQL_STATE_ILLEGAL_ARGUMENT, getExceptionInterceptor()); } .... }} |
上述报错信息是PreparedStatement.34和PreparedStatement.35,查mysql connector的LocalizedErrorMessages.properties
|
1
2
|
PreparedStatement.34=Connection is read-only.PreparedStatement.35=Queries leading to data modification are not allowed |
报错信息一致。
因此, 如果是使用的主备mysql,需要手动切换master和slave,如果使用的是多主的mysql(例如,phxsql),需要设置failoverReadOnly=false
Connection is read-only. Queries leading to data modification are not allowed的更多相关文章
- java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
org.springframework.dao.TransientDataAccessResourceException: ### Error updating database. Cause: ja ...
- 执行update操作的话,就会报“Connection is read-only. Queries leading to data modification are not allowed”的异常。
我用的是 spring + springmvc + mybatis +mysql. <tx:advice id="txAdvice" transaction-manager= ...
- java最全的Connection is read-only. Queries leading to data modification are not allowed
Connection is read-only. Queries leading to data modification are not allowed 描述:框架注入时候,配置了事物管理,权限设置 ...
- [Done]java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed ...
- 详细解读 :java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed,Java报错之Connection is read-only.
问题分析: 实际开发项目中,进行insert的时候,产生这个问题是Spring框架的一个安全权限保护方法,对于方法调用的事物保护,一般配置如下: <!-- 事务管理 属性 --> < ...
- Connection is read-only. Queries leading to data modification are not allowed 错误原因
因为我再spring 中使用了AOP进行事务管理,有如下配置 <tx:advice id="txAdvice" transaction-manager="trans ...
- 执行新增和修改操作报错connection is read-only. Queries leading to data modification are not allowed
出现这个问题的原因是默认事务只有只读权限,因此要添加下面的每一个add*,del*,update*等等. 分别给予访问数据库的权限. 方法名的前缀有该关键字设置了read-only=true,将其改为 ...
- Chapter Data Modification & Chapter Data Validation
Chapter Data Modification XF的数据提交,支持单行.集合和多层次的master-details结构的数据. Create 当提交如下数据 <Job> <Id ...
- Spring事务报Connection is read-only
昨天做项目时,写了个方法,程序突然报了Connection is readonly. Queries leading to data modification are not allowed调了程序半 ...
随机推荐
- 性能测试十三:linux常用命令
常用的linux命令: 目录类/ 根目录. 当前目录.. 上级目录cd / 进入根目录cd .. 进入上级目录ls 查看当前目录下的所有文件ll 查看当前目录下所有文件的详细信息pwd 显示当前目录的 ...
- web中切图、快速切图与web雪碧图制作的方法
声明: web小白的笔记,欢迎大神指点,联系QQ:1522025433. 工具:Photoshop 1.复制文字:点击文章工具后选择文字. 2.矩形选框工具 看信息 f8, 取消矩形选框 Ctrl+D ...
- python 全栈开发,Day5(字典,增删改查,其他操作方法)
一.字典 字典是python中唯一的映射类型,采用键值对(key-value)的形式存储数据.存储大量的数据,是关系型数据,查询数据快. 列表是从头遍历到尾字典使用二分查找 二分查找也称折半查找(Bi ...
- 【C++】拷贝构造函数(深拷贝,浅拷贝)详解
一.什么是拷贝构造函数 首先对于普通类型的对象来说,它们之间的复制是很简单的,例如: ; int b = a; 而类对象与普通对象不同,类对象内部结构一般较为复杂,存在各种成员变量. 下面看一个类对 ...
- poj 1631 最多能有多少条不交叉的线 最大非降子序列 (LIS)
左边的数字是1 2 3 4 5.... 右边的数字 第一个输入的和1连 第2个输入的和2连 右边再按从小到大排序 要求连线不能交叉 问最多能有多少条不交叉的线 假如右边有5个1 那么答案会是5 所以是 ...
- jenkins X实践系列(1) —— 背景知识
本文介绍jenkins X(以下简称jx)相关的背景技术. jenkins X 简介 Jenkins X 是一个高度集成化的CI/CD平台,基于Jenkins和Kubernetes实现,旨在解决微服务 ...
- java之定时器任务Timer用法
在项目开发中,经常会遇到需要实现一些定时操作的任务,写过很多遍了,然而每次写的时候,总是会对一些细节有所遗忘,后来想想可能是没有总结的缘故,所以今天小编就打算总结一下可能会被遗忘的小点: 1. pub ...
- k8s 使用详解
转自:https://www.cnblogs.com/gaoyuechen/p/8685771.html
- Unity 之 插件下载
Inventory Pro2.3.1: https://mega.nz/#!MIIx1bqI!_nTHyvT1IJsAxOtSEp_cSnc2OL9pqF3EBXS_N143_X8 NGUI 3.11 ...
- Linux使用tcpdump命令抓包并使用wireshark分析
Linux使用tcpdump命令抓包并使用wireshark分析 介绍 有时分析客户端和服务器网络交互的问题时,为了查找问题,需要分别在客户端和服务器上抓包,我们的客户端一般是windows上的,抓包 ...