20. 32. 1. JDBC Transaction Isolation Levels |
|
Connection.setTransactionIsolation (level)
|
|
JDBC Defined Constant | Description | TRANSACTION_READ_UNCOMMITTED | Allows dirty reads, non-repeatable reads, and phantom reads to occur. | TRANSACTION_READ_COMMITTED | Ensures only committed data can be read. | TRANSACTION_REPEATABLE_READ | Is close to being "serializable," however, "phantom" reads are possible. | TRANSACTION_SERIALIZABLE | Dirty reads, non-repeatable reads, and phantom reads are prevented. Serializable. |
|
A "phantom" read occurs when one transaction reads all rows that satisfy a WHERE condition, and a second transaction inserts a row that satisfies that WHERE condition, the first transaction then rereads for the same condition, retrieving the additional "phantom" row in the second read.
(from book: JDBC Recipes A Problem-Solution Approach) |
In addition, JDBC defines an additional constant, TRANSACTION_NONE, which is used to indicate that the driver does not support transactions. |