There are two types of transaction management mechanisms: Programmatic transaction management and declarative transaction management.
1. The programmatic transaction management enterprise has not been used.
2. We are mainly talking about declarative transaction management. Declarative transaction management, no need to modify the original code, only need to configure, for the target code to add transaction management, AOP underlying implementation---enterprise recommendation
Here's a case: through Spring declarative transaction management. Implement the transfer case.
First step: Build a table;
The table statement is as follows: two accounts in account (AAA and BBB)
CREATE TABLE ' account ' ( ' id ' int (one) not null auto_increment, ' name ' varchar () ' = ' NOT null ', ' money ' double DEF Ault NULL, PRIMARY KEY (' id ')) engine=innodb auto_increment=4 DEFAULT charset=utf8;insert into ' account ' VALUES (' 1 ', ' AAA ', ' + '); INSERT into ' account ' VALUES (' 2 ', ' BBB ', ' 1000 ');
Step Two: Create a project Spring3_day3_transactionmanager
Import IOC core 4, log 2
Test A
AOP 4 x
JDBC 2 x
Database drives A
C3P0 A
Introduction of Applicationcontext.xml, Db.properties, log4j.properties
Two kinds of mechanism of 25SPRING_ transaction management