java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
org.springframework.dao.TransientDataAccessResourceException:
### Error updating database. Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: UPDATE wed_trans SET status=?, st_time=DATE_FORMAT(NOW(),'%Y%m%d%H%i%S') WHERE order_no=?
### Cause: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
; SQL []; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:106) ~[SQLStateSQLExceptionTranslator.class:4.0.9.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[AbstractFallbackSQLExceptionTranslator.class:4.0.9.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[AbstractFallbackSQLExceptionTranslator.class:4.0.9.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) ~[AbstractFallbackSQLExceptionTranslator.class:4.0.9.RELEASE] Caused by: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
解决方法:事务配置在service层,但是你的service层的方法是query开头的,service调用的query方法根本就没有事务。你的配置文件下面是不是还有关于query*的配置成了read-only?修改你service方法的开头变成不是read-only的那种配置,如clear开头。(在query方法名(read_only)里面执行了update操作,所以就报错了。)
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <!-- 声明式事物管理 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="load*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="add*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="save*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="insert*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="update*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="modify*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="delete*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="del*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="registe*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="approve*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="clear*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="set*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="reset*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="getUpdate*" read-only="false" rollback-for="Exception" propagation="REQUIRED"/>
<!-- <tx:method name="*" read-only="true"/> -->
</tx:attributes>
</tx:advice>
java.sql.SQLException: 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最全的Connection is read-only. Queries leading to data modification are not allowed
Connection is read-only. Queries leading to data modification are not allowed 描述:框架注入时候,配置了事物管理,权限设置 ...
- Connection is read-only. Queries leading to data modification are not allowed
看了下mysql-connector-5.1.40版本中,如果设置failoverReadOnly=true (即默认值,参考链接),当mysql连接failover时,会根据jdbc连接串将当前连接 ...
- 执行update操作的话,就会报“Connection is read-only. Queries leading to data modification are not allowed”的异常。
我用的是 spring + springmvc + mybatis +mysql. <tx:advice id="txAdvice" transaction-manager= ...
- 详细解读 :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,将其改为 ...
- java.sql.SQLException: connection holder is null;
一.问题来源分析 出现的错误 : Cause: java.sql.SQLException: connection holder is null; uncategorized SQLException ...
- java.sql.SQLException: connection holder is null 问题处理
问题描述 上上个周测试的时候突然报系统异常,于是我立即查看日志,发现是一个数据库异常:java.sql.SQLException: connection holder is null我第一想到的就是可 ...
随机推荐
- rails的字符编码
想练练手,随意的写了个登陆页面,简单的只有几行. <%= form_tag('login_check') do -%><%= text_field_tag 'user_name', ...
- SSH使用缩写
需要经常ssh到其它机器上,但如果每次都使用主机命名或ip地址,那挺难受的.这里有2个方法可以在ssh登陆时缩写(简写)主机名. 1. 在~/.ssh中添加config文件 [toughhou@hd1 ...
- 惊曝6.24AppCan移动开发大会参展名录,现场礼品超多!
AppCan移动开发者大会召开在即, 诸位参展商准备就绪, 移动圈的半边天都来了, 现场活动和礼品多到爆炸, 请大家一一过目! 排名不分先后,AppCan不偏心! 1.极验验证 首创滑动式拼图验证码. ...
- Media Player(APP)
今天共享一下,以前做的影音播放器.比较简单.适合新手. 我上传了附件可以参考一下. PDF:http://files.cnblogs.com/files/hongguang-kim/MediaPlay ...
- C++函数传指针和传引用的区别
从概念上讲.指针从本质上讲就是存放变量地址的一个变量,在逻辑上是独立的,它可以被改变,包括其所指向的地址的改变和其指向的地址中所存放的数据的改变. 而引用是一个别名,它在逻辑上不是独立的,它的存在具有 ...
- Python修饰器的函数式编程
Python的修饰器的英文名叫Decorator,当你看到这个英文名的时候,你可能会把其跟Design Pattern里的Decorator搞混了,其实这是完全不同的两个东西.虽然好像,他们要干的事都 ...
- 【分享】生成Revit扩展的addin文件小工具
在进行Revit二次开发的时候,加载命令/程序使用的是添加addin文件的方式,每次都需要手动的写,而且参数有好多,很不方便.于是乎我有了写一个小工具的想法.进过研究终于完成了.主要使用RevitAd ...
- ListBox mvvm 学习笔记
1. ListBox MvvM 例子1. 简单的绑定,ItemsSource 绑定到一个实现了IEnumerable 的类上.一般该绑定都是双向的,所以优先考虑使用 ObservableCollec ...
- 45.modelsim仿真include文件
modelsim仿真include文件会出现找不到文件的情况,这是因为include文件路径有两种,一种是相对路径,另一种是绝对路径. 相对路径: 如果 ‘include "primitiv ...
- ios coreData使用
ios中的coredata的使用(转) 分类: ios2013-07-15 18:12 27288人阅读 评论(1) 收藏 举报 Core Data数据持久化是对SQLite的一个升级,它是ios集成 ...