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的更多相关文章

  1. [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 ...

  2. 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 描述:框架注入时候,配置了事物管理,权限设置 ...

  3. Connection is read-only. Queries leading to data modification are not allowed

    看了下mysql-connector-5.1.40版本中,如果设置failoverReadOnly=true (即默认值,参考链接),当mysql连接failover时,会根据jdbc连接串将当前连接 ...

  4. 执行update操作的话,就会报“Connection is read-only. Queries leading to data modification are not allowed”的异常。

    我用的是 spring + springmvc + mybatis +mysql. <tx:advice id="txAdvice" transaction-manager= ...

  5. 详细解读 :java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed,Java报错之Connection is read-only.

    问题分析: 实际开发项目中,进行insert的时候,产生这个问题是Spring框架的一个安全权限保护方法,对于方法调用的事物保护,一般配置如下: <!-- 事务管理 属性 --> < ...

  6. Connection is read-only. Queries leading to data modification are not allowed 错误原因

    因为我再spring 中使用了AOP进行事务管理,有如下配置 <tx:advice id="txAdvice" transaction-manager="trans ...

  7. 执行新增和修改操作报错connection is read-only. Queries leading to data modification are not allowed

    出现这个问题的原因是默认事务只有只读权限,因此要添加下面的每一个add*,del*,update*等等. 分别给予访问数据库的权限. 方法名的前缀有该关键字设置了read-only=true,将其改为 ...

  8. java.sql.SQLException: connection holder is null;

    一.问题来源分析 出现的错误 : Cause: java.sql.SQLException: connection holder is null; uncategorized SQLException ...

  9. java.sql.SQLException: connection holder is null 问题处理

    问题描述 上上个周测试的时候突然报系统异常,于是我立即查看日志,发现是一个数据库异常:java.sql.SQLException: connection holder is null我第一想到的就是可 ...

随机推荐

  1. 开机一会,出现长时间闪屏,并且跳出SendRpt error

    通过谷歌,发现任务管理器中的Report sending utility 是属于TortoiseSVN 的,所以卸载svn ,然后重启就ok了

  2. ORACLE DG之参数详解

    1.DB_NAME 数据库名字,需要保持同一个Data Guard中所有数据库DB_NAME相同. 主库和备库相同 DB_NAME='chicago' DB_NAME='chicago' 2.DB_U ...

  3. N进制数组转换成正整数

    给定一个任意长度的数组,其中的元素按照一定的进制(N进制)来转换成正整数 //把数组中的元素按照N进制转换成为正整数 #include <stdio.h> #include <std ...

  4. java-servlet-jsp

    =========================servletjavax.servlet    javax.servlet.http    javax.annotation    javax.ser ...

  5. javascript中方法调用与方括号[]

    看jquery时遇到一行: $(this)["removeClass"]("selected"); 这一行等同于下面的一行: $(this).removeCla ...

  6. C# 添加一个用户对文件或者文件夹的所有权限

    private void ModifyFilePermission(string path, string user, FileType filetype) { if (filetype == Fil ...

  7. python2 编码问题详解

    实例对比 定义 type str unicode print encode('utf8') decode('utf8') encode('unicode-escape') encode('string ...

  8. asp.net web.config 经典模式和集成模式相关配置

    <?xml version="1.0"?> <configuration> <!--IIS经典模式下使用--> <system.web&g ...

  9. JAVA事务

    一.什么是事务 我们通常会认为事务与数据库有关. 事务是访问数据库的一个操作序列,数据库应用系统通过事务集来完成对数据库的操作.事务的正确执行使得数据库从一种状态转换成另外一种状态. 事务必须服从IS ...

  10. viewport使用 html5

    viewport 语法介绍: 01 02 width 控制 viewport 的大小,可以指定的一个值或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的 ...