Mega Code Archive

 
Categories / Java Tutorial / Database
 

JDBC Transaction Isolation Levels

Connection.setTransactionIsolation (level) JDBC Defined ConstantDescription TRANSACTION_READ_UNCOMMITTEDAllows dirty reads, non-repeatable reads, and phantom reads to occur. TRANSACTION_READ_COMMITTEDEnsures only committed data can be read. TRANSACTION_REPEATABLE_READIs close to being "serializable," however, "phantom" reads are possible. TRANSACTION_SERIALIZABLEDirty 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.