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

来源:互联网 发布:看报纸的软件 编辑:程序博客网 时间:2024/04/28 04:50

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


0 0
原创粉丝点击