Error updating database. Cause: java.sql.SQLException: Connection is read-only. Queries leading to

       最近公司一个老项目,更新数据库报这个错误。一般是方法名字不对(配置里面设置了,比如说,方法名字中带有get的,不让修改数据)。

   

    <aop:config <aop:advisor pointcut-ref="servicePointcut" advice-ref="txAdvice"/> </aop:config> <!-- 事务的传播特性 --> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" propagation="REQUIRED" read-only="true"/> <tx:method name="find*" propagation="REQUIRED" read-only="true"/> <tx:method name="query*" propagation="REQUIRED" read-only="true"/> </tx:attributes>

    <aop:config <aop:advisor pointcut-ref="servicePointcut" advice-ref="txAdvice"/>

    </aop:config> <!-- 事务的传播特性 -->

<tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes>

<tx:method name="get*" propagation="REQUIRED" read-only="true"/>

<tx:method name="find*" propagation="REQUIRED" read-only="true"/>

<tx:method name="query*" propagation="REQUIRED" read-only="true"/> </tx:attributes>

比如说上面这种配置,就是方法里面包含有get、find、query的(以这个开头的),就会默认你是查询,如果你这个方法其实是更新数据,那就报错了。所以解决办法就是,如果你是更新数据的方法,那就不要出现get、find、query,另外起一个别的名字。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值