# tx **Repository Path**: l23456789o/tx ## Basic Information - **Project Name**: tx - **Description**: spring 事务机制 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-18 - **Last Updated**: 2024-04-09 ## Categories & Tags **Categories**: Uncategorized **Tags**: 事务 ## README # spring 的事务机制 1.连接数据库 ```bash #mysql spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/tx?useUnicode=true&characterEncoding=UTF-8&useSSL=true spring.datasource.username=root spring.datasource.password=!QAZ2wsx ``` 2.创建2张表 >> 见doc中的all.sql 3.往数据表里插入数据的sql ```sql insert into table_a(id,create_date) VALUES(null,NOW()); insert into table_b(id,create_date) VALUES(null,NOW()); ``` 4.创建bean对象 参考资料:[带你读懂Spring 事务——事务的传播机制](https://zhuanlan.zhihu.com/p/148504094) [MySQL的四种事务隔离级别](https://www.cnblogs.com/huanongying/p/7021555.html)