事务02-事务案例-转账:不使用Spring事务管理的实现(Spring 笔记012)

1.新建account表
2.导入jar包
{ 核 心 与 依 赖 : 4 + 1 a o p ( a o p 联 盟 , s p r i n g    a o p , a s p e c t 规 范 , s p r i n g    a s p e c t ) 数 据 库 : j d b c + t x + 数 据 库 驱 动 包 / 连 接 池    + c s p o \left\{\begin{array}{l}\mathrm{核心与依赖}:4+1\\aop(aop\mathrm{联盟},spring\;aop,aspect\mathrm{规范},spring\;aspect)\\\mathrm{数据库}:jdbc+tx+\mathrm{数据库驱动包}/\mathrm{连接池}\;+cspo\\\end{array}\right. 4+1aop(aopspringaop,aspectspringaspect)jdbc+tx+/+cspo
3.转账事务管理类

在这里插入图片描述

public class AccountServiceImpl implements AccountService{
    
    
private accountDao accountdao;
public void setAccountDao (AccountDao accountDao){
    
    
  rhis.accountDao=accountDao;}
public void transfer(String outer,String inner ,Integer money) {
    
    
accountDao.out(outer,money);
int i=1/0;//断电
accountDao.in(inner,money);
 }
}

猜你喜欢

转载自blog.csdn.net/ResumeProject/article/details/112935388