JDBC Transaction Management Example---reference
发布时间:2020-12-14 06:20:21 所属栏目:Java 来源:网络整理
导读:In this post,we want to talk about JDBC Transactions and how we can manage the operations in a database. The most popular DBMS like MySQL and Oracle have by default the option autocommit enabled,it means immediately after any DML Operation
In this post,we want to talk about JDBC Transactions and how we can manage the operations in a database. The most popular DBMS like MySQL and Oracle have by default the option autocommit enabled,it means immediately after any DML Operation saves the changes and makes them visible to all users. To use transactions must set the databse parameter? The management of the database using transaction allows us to maintain consistency in the data,according to his ‘ACID’ property. Transaction PropertiesWhat we want with Transactions? To Maintain this four properties:
ToolsFor this example we use:
1. Example:DBConnection.java:
|
04?
05?
06
07
08
09
10
11??
12
13??
14??
15??
16
17???
18
19?
20
21
We use?DBConnection
?only to get the connection,any other operation is handled in the main class.
DBTransaction.java:
01?
02
03?
04?
05?
06
07
08
09
10
11??
12
13??
14
15
16
17
18???
19
20
21
22?
23
24?
25
26
27?
28
29
30?
31
32
33
34?
35
36
37?
38
39
40
41?
42
43
44
45?
46
47