解决mysql LOCK TABLES 后事务无法回滚的问题
2017-02-24 18:07
393 查看
在spring mvc+ mybatis中定义了一个事务,事务是service 层的一个方法fun1如
try{
....
lock tables ...
}finally{
unlock tables...;
}
坑来了,这样会导致fun1不会回滚,解决是在Controller层来释放锁,即锁释放不能在fun1中释放,
如
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
ModelAndView mav = new ModelAndView();
Result result = new Result();
try {
result = upListService.updataListGoodsEx(code,goodsNumStr,goodsIdStr,teamIdStr,goodsPriceStr,user.getStructId());
} catch (Exception e) {
result.setMsg(e.getMessage());
}finally {
sfm.unlockTable(null);
}
return CheckUtil.returnResult(mav, result.getCode(), result.getMsg()
, result.getData());
}
try{
....
lock tables ...
}finally{
unlock tables...;
}
坑来了,这样会导致fun1不会回滚,解决是在Controller层来释放锁,即锁释放不能在fun1中释放,
如
public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
ModelAndView mav = new ModelAndView();
Result result = new Result();
try {
result = upListService.updataListGoodsEx(code,goodsNumStr,goodsIdStr,teamIdStr,goodsPriceStr,user.getStructId());
} catch (Exception e) {
result.setMsg(e.getMessage());
}finally {
sfm.unlockTable(null);
}
return CheckUtil.returnResult(mav, result.getCode(), result.getMsg()
, result.getData());
}
相关文章推荐
- Proxool+hibernate+spring时事务自动回滚导致无法提交的问题解决
- MySQL表类型MyISAM/InnoDB的区别(解决事务不回滚的问题)(转)
- 终极办法:解决spring mvc+mysql+mybatis事务不提交不回滚的问题
- 解决Mysql收缩事务日志和日志文件过大无法收缩问题
- 解决AssignmentHandler 出现异常事务无法回滚问题
- mybatis整合spring、springmvc时业务层无法进行事务回滚问题解决
- MySql 执行事务无效无法回滚问题
- MySQL 客户端无法连接 mysqld-nt 问题的解决
- MySQL 5.1 无法创建、修改存储过程的解决(简单问题)
- 防火墙导致MySQL无法访问的问题解决案例
- 从源码安装mysql无法定位basedir问题的解决方法
- 解决问题E: 无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用) E: 无法锁定管理目录
- spring3MVC 事务无法回滚问题
- windows下Mysql解决Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
- 解决MySQL进程无法启动的问题
- 解决“COM+ 无法与 Microsoft 分布式事务协调程序交谈”的问题
- mysql下普通用户备份数据库时无lock tables权限的解决方法
- 解决远程无法登陆mysql服务器的问题和重置密码
- Ubuntu下MySQL Query Browser无法登陆??HELP!(问题已解决)
- 安装PHP可能遇到的问题“无法载入mysql扩展” 的解决方法