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调了程序半 ...
随机推荐
- python 全栈开发,Day100(restful 接口,DRF组件,DRF跨域(cors组件))
昨日内容回顾 1. 为什么要做前后端分离? - 前后端交给不同的人来编写,职责划分明确.方便快速开发 - 针对pc,手机,ipad,微信,支付宝... 使用同一个接口 2. 简述http协议? - 基 ...
- python 全栈开发,Day23(复习,isinstance和issubclass,反射)
一.复习 class A: def func1(self):pass def func2(self): pass def func3(self): pass a = A() b = A() print ...
- ef 数据库连接字符串加密
public testContext() : base(GetConnection(), true) { } public static DbConnection GetConnection() { ...
- 华为交换机SNMP OID
http://vbb.fyjy.net:88/showthread.php?t=4647
- Codeforces 757 C Felicity is Coming!
题目大意:有n个训练营,m种宠物,每个训练营里里面有gi 个宠物,现在每只宠物都要完成一次进化,种类 相同的宠物进化之后,种类还是相同,种类不同的宠物不能进化成相同种类,且要求所有宠物进化之后,每个 ...
- 2.Django|简介与静态文件| URL控制器
1.简介 MVC Web服务器开发领域里著名的MVC模式,所谓MVC就是把Web应用分为模型(M),控制器(C)和视图(V)三层,他们之间以一种插件式的.松耦合的方式连接在一起,模型负责业务对象与数 ...
- 【Java】 剑指offer(8) 用两个栈实现队列
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 用两个栈实现一个队列.队列的声明如下,请实现它的两个函数append ...
- 033 关于YARN的HA
一:准备 1.规划 namenode namenode ZKFC ZKFC journalnode journalnode jou ...
- HDU 2844 Coins 【多重背包】(模板)
<题目连接> 题目大意: 一位同学想要买手表,他有n种硬币,每种硬币已知有num[i]个.已知手表的价钱最多m元,问她用这些钱能够凑出多少种价格来买手表. 解题分析: 很明显,这是一道多重 ...
- PyQt5初级教程(一)
python 版qt入门级使用说明 我使用的是python3.5安装PyQt5: pip3 install PyQt5 可以用如下代码测试环境是否安装成功,运行成功会弹出一个窗口: from PyQt ...