Jdbc oracle Database isolation level

Source: Internet
Author: User

Jdbc oracle Database isolation level
Database isolation level:
When these transactions access the same data in the database, if the necessary isolation mechanism is not adopted, various concurrency problems will occur:
Dirty read: For two objects T1, T2, T1, after reading fields that have been updated by T2 but have not been submitted, if T2 rolls back,
The content read by T1 is temporary and invalid.
Repeatable reading: one field is read for T1, T2, and T1, and then T2. after T2. T1 reads the same field again, the value is different.
Phantom read: For two pairs of things T1, T2, T1 read a field from a table, and T2 inserts some new rows in the table.
Then, if T1 reads the same table again, there will be several more rows.
Database transaction isolation: the database system must be able to isolate and concurrently run various transactions so that they do not affect each other and avoid various concurrency problems.
The degree of isolation between a transaction and other transactions is called the isolation level. The database specifies multiple transaction isolation levels, and different isolation levels correspond to different interference levels,

The higher the isolation level, the better the data consistency, but the weaker the concurrency.

Isolation level in JDBC Conntion class
Int TRANSACTION_NONE = 0;
// Read uncommitted data
Int TRANSACTION_READ_UNCOMMITTED = 1;
// Read submitted data
Int TRANSACTION_READ_COMMITTED = 2;
// Repeatable read data: make sure that a transaction can read the same value from a field multiple times, and prohibit other tasks from updating the transaction during the duration of the transaction,
// Avoid dirty and non-repeated data reading, but Phantom read still exists.
Int TRANSACTION_REPEATABLE_READ = 4;
// Serial: make sure that a transaction can read the same row from a table. During this period, other things are prohibited from performing insert update and delete operations on the table,
// All concurrency problems can be avoided, but the efficiency is very low
Int TRANSACTION_SERIALIZABLE = 8;

Two transaction isolation levels supported by Oracle: read commited and SERIALIZABLE. The default transaction isolation level of Oracle is read commited.


Sometimes it is necessary to set the transaction isolation level in the Code:
Connection. setTransactionIsolation (Connection. TRANSACTION_NONE );

Related Article

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.