JDBC ORACLE Database Isolation Level

Source: Internet
Author: User

Isolation level of the database:
Multiple transactions that run concurrently, when these transactions access the same data in the database, can cause various concurrency problems if the necessary isolation mechanism is not taken:
Dirty reads: For two things T1, T2, T1 read the fields that have been T2 updated but have not yet been committed. After that, if T2 rolls back,
The content read by T1 is temporary and invalid.
Non-repeatable READ: For two things T1, T2, T1 read a field, and T2 updated the field. After that, T1 reads the same field again, and the value is different.
Phantom reading: For two pairs of things T1, T2, T1 reads a field from a table, and then T2 inserts some new rows into the table.
Then, if T1 reads the same table again, it will have a few more rows.
Database transaction Isolation: The database system must have the ability to isolate and run each transaction concurrently, so that they do not affect each other and avoid various concurrency problems.
The degree to which a transaction is isolated from other transactions is called the isolation level. The database specifies a variety of transaction isolation levels, which correspond to different levels of interference,

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


Isolation level in the 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 things can read the same value from a field multiple times, and prohibit other things from being updated when things persist.
You can avoid data dirty reads and non-repeatable reads, but Phantom reads still exist
int transaction_repeatable_read = 4;
Serial session: Make sure things can read the same rows from a table, prohibit other things from inserting updates and deletes to the table during this thing's duration,
All concurrency problems can be avoided, but the efficiency is very low.
int transaction_serializable = 8;

2 Kinds of transaction isolation levels supported by Oracle: READ commited, SERIALIZABLE. The default transaction isolation level for Oracle is: READ commited


It is sometimes necessary to set the object isolation level in your code:
Connection.settransactionisolation (Connection.transaction_none);

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

JDBC ORACLE Database Isolation Level

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.