Connection is read-only. Queries leading to data modification are not allowed 错误原因
因为我再spring 中使用了AOP进行事务管理,有如下配置
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义事务传播属性 -->
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="new*" propagation="REQUIRED" />
<tx:method name="set*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="change*" propagation="REQUIRED" />
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
对于get find load 开头和其他所有方法都设置了只读,不能修改、删除、插入 操作。而我执行的方法名以Insert 开头大小写不一致导致当前事务是只读的,执行插入操作就会报以上错误。
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
		
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= ...
 - Connection is read-only. Queries leading to data modification are not allowed
		
看了下mysql-connector-5.1.40版本中,如果设置failoverReadOnly=true (即默认值,参考链接),当mysql连接failover时,会根据jdbc连接串将当前连接 ...
 - 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 描述:框架注入时候,配置了事物管理,权限设置 ...
 - 详细解读 :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
		
出现这个问题的原因是默认事务只有只读权限,因此要添加下面的每一个add*,del*,update*等等. 分别给予访问数据库的权限. 方法名的前缀有该关键字设置了read-only=true,将其改为 ...
 - Chapter Data Modification & Chapter Data Validation
		
Chapter Data Modification XF的数据提交,支持单行.集合和多层次的master-details结构的数据. Create 当提交如下数据 <Job> <Id ...
 - System.Data.OleDb.OleDbException: 未指定的错误的解决方法
		
异常详细信息: System.Data.OleDb.OleDbException: 未指定的错误 这个错误是access数据库特有的错误,当access频繁读取或操作过多的时候就会发生这个错误,微软官 ...
 
随机推荐
- Word:图片压缩
			
造冰箱的大熊猫,本文适用于Microsoft Word 2007@cnblogs 2018/12/1 图片插入Word文档后,可以通过“裁剪”功能只显示图片的部分区域.虽然文档中显示的图片区域变小了, ...
 - TTTTTTTTTTTTTTTT      POJ  2723   楼层里救朋友   2-SAT+二分
			
Get Luffy Out Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8211 Accepted: 3162 Des ...
 - 4.JSP内置对象
			
JSP内置对象,JSP提供了由容器实现和管理的内置对象,也可以称之为隐含对象,这些内置对象不需要通过 JSP页面编写来实例化,在所有的JSP页面中都可以直接使用,它起到了简化页面的作用. 在JSP中一 ...
 - Python实用黑科技——找出最大/最小的n个元素
			
需求: 快速的获取一个列表中最大/最小的n个元素. 方法: 最简便的方法是使用heapq模组的两个方法nlargest()和nsmallest(),例如: In [1]: import heapqIn ...
 - PyCharm将main.py解析成text文件的解决方法
			
问题:PyCharm将main.py解释成文本文件,没有代码提示,也无法执行 解决方法:File->Settings->Editor->File Types ->选则Text ...
 - python 生成随机数的几种方法
			
随机取一个: import random random.choice(string.digits)#从数字里随机选取一位数字: 随机取多位数: random.sample(string.dig ...
 - 一款兼容性较强的H5播放器-Mediaelementjs
			
特别提示:本人博客部分有参考网络其他博客,但均是本人亲手编写过并验证通过.如发现博客有错误,请及时提出以免误导其他人,谢谢!欢迎转载,但记得标明文章出处:http://www.cnblogs.com/ ...
 - yue
			
1. 字节流与二进制文件 1.我的代码 public class Student { private int id; private String name; private int age; pri ...
 - Typography 字体
			
Typography 字体 我们对字体进行统一规范,力求在各个操作系统下都有最佳展示效果. ¶中文字体 和畅惠风 PingFang SC 和畅惠风 Hiragino Sans GB 和畅惠风 Micr ...
 - nodejs之express框架商品管理系统登录功能
			
1.该系统主要使用express.body-parser.express-session.ejs.mongodb-connect . npm install express --save npm in ...