`
liukai
  • 浏览: 702372 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

mysql查询错误(Connection is read-only)的1个解决方案

阅读更多
Connection is read-only. Queries leading to data modification are not allowed


如果出现以上的错误可能是由于事务配置文件上
<tx:advice id="txAdvice">
		<tx:attributes>
			<tx:method name="*" read-only="true" />
			<tx:method name="insert*" />
			<tx:method name="update*" />
			<tx:method name="delete*" />
		</tx:attributes>
	</tx:advice>

当方法名字开头不包含指定的名字时 会自动用默认的事务
但此事务是read_only="true" 所以才有"Connection is read-only. Queries leading to data modification are not allowed"的错误
解决方案有2种
1.规范命名
2.删除
<tx:method name="*" read-only="true" />

(不推荐)
分享到:
评论
3 楼 liukai 2012-01-09  
warnerhit 写道
还是出错啊

很久以前写的一篇blog了.
其实报错的原因很简单.
你的方法名违背了你定义的事务配置.
比如你的更新方法开头是update*** ,
而你写成了edit**.
会报错.因为事务辨别不了你的方法到底应该用什么级别的.
所以会用默认的 * .
而* 是read-only="true"的.
2 楼 warnerhit 2012-01-09  
还是出错啊
1 楼 davos 2010-01-07  
用你的第二种方法解决问题了,但还是不清楚为什么

相关推荐

Global site tag (gtag.js) - Google Analytics