Java Basics-Transaction

Source: Internet
Author: User

First, the business

Simply put, business is just one thing. All transaction-related content is carried out around the same thing.

Second, the characteristics of the transaction: ACID

A:atomicity (atomicity), a transaction must be an indivisible whole.

C:consistency (consistency), the data is not destroyed after the database operation is performed. such as: From a account transfer to B, to ensure that a account deduction, B account can increase the amount of money.

I:isolation (isolation), many people in the same data at the same time to operate, if not to control, it will cause a lot of trouble. And this control means isolation.

D:durability (persistent), if an INSERT statement is executed, the database must ensure that a single piece of data is permanently stored in the database.

The ACID property of the transaction is to ensure the consistency of the data. Isolation is a means of ensuring transactional consistency.

Iii. Isolation levels of transactions (Transanction isolation Level)

As stated above, the isolation of transactions. The control referred to here is the isolation level.

(1) Read_uncommited: Read not submitted

(2) Read_commited: Read submitted

(3) Repeatable_read: Repeatable reading

(4) SERIALIZABLE:

From the top down, concurrency is getting worse, and security is getting higher.

Iv. issues existing in the transaction

(1) Dirty read--transaction a reads the uncommitted data from transaction B and does other things on this basis.

(2) Non-repeatable read-transaction a reads the changed data submitted by transaction B.

(3) Phantom read-transaction A reads the new data that has been submitted by transaction B.

No matter under what circumstances, dirty reading is not allowed.

V. The correspondence between the isolation level of the transaction and the problems in the transaction

In fact, the existence of the isolation level of the transaction is in itself to solve the problem in the transaction.

The default isolation level for MySQL is read_commited.

It should be recalled that the transaction isolation level specification described here is JDBC.

To the database level, the isolation level is controlled by locks, and when data is inserted, the lock table is called the "lock table". When the data is updated, the lock line is called "Lock Line".

Java Basics-Transaction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.