ssh中Connection is read-only问题的产生原因与解决方法

ssh中Connection is read-only问题的产生原因与解决方法 

在前段时间用ssH 写一个小例子,怎么都不能插入数据,看报错是;“Connection is read-only. Queries leading to data modification are not allowed

后来查阅资料才知道般如果报了这个错,估计是ssh中事物配置文件的问题。

<!-- 拦截器方式配置事物 -->
<tx:advice id="transactionAdvice" transaction-manager="transactionManager">
   <tx:attributes>
      <tx:method name="save*" propagation="REQUIRED" />
      <tx:method name="insert*" propagation="REQUIRED"  read-only="true"/>

      <tx:method name="add*" propagation="REQUIRED" />
      <tx:method name="do*" propagation="REQUIRED" />
      <tx:method name="update*" propagation="REQUIRED"  read-only="true"/>
      <tx:method name="change*" propagation="REQUIRED" />
      <tx:method name="edit*" propagation="REQUIRED"/>
      <tx:method name="process*" propagation="REQUIRED" />
      <tx:method name="saveOrUpdate*" propagation="REQUIRED" />
      <tx:method name="delete*" propagation="REQUIRED" />
      <tx:method name="grant*" propagation="REQUIRED" />
      <tx:method name="llm*" propagation="REQUIRED" />
      <tx:method name="init*" propagation="REQUIRED" />

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

这里面规定了数据库操作函数必须要以以上字符串开头,否则的话就按照默认的配置,对数据库访问的权限为read-only。

所以很有可能是你起了一个名字,不在你的配置库中。
一般来说一个数据库操作类XXService都是继承基类 DAO.
数据库操作类XXService中的方法在执行的时候,会和事务配置表中的进行对比,并赋给相应的权限。

解决办法:
解决方案有2种
1.规范命名
2.删除read-only="true" ,但是这种方法不推荐,因为有可能会出现一些你想不到的问题,或者是对服务器的性能造成影响。

3.把你新起的名字的方法,配置到里面,标红的是我自己写的时候没有配置的方法,配置上后问题完美的结局。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值