Java Reference
In-Depth Information
Most JDBC drivers support transactions. In fact, a JDBC-compliant driver must
support transactions. DatabaseMetaData supplies information describing the level of
transaction support a DBMS provides.
Transaction Isolation Levels
The basic concept of transaction management allows us to manage simple conflicts
arising from events such as a failure to complete a linked series of SQL commands.
However, other types of conflict can occur that require additional levels of
management.
For example, consider the case of a multiuser application, where one transaction has
initiated a transfer between two accounts but has not yet committed it, when a second
transaction attempts to access one of the accounts in question. If the first transaction
is rolled back, the value the second transaction reads will be invalid. Depending on
the application, this situation may be acceptable, but in many financial applications, it
would probably be quite unacceptable.
JDBC defines five levels of transaction isolation that provide different levels of conflict
management. The lowest level specifies that transactions are not supported at all,
and the remainder map to the four isolation levels that SQL -92 defines. These are as
follows:
 
Read Uncommitted
 
Read Committed
 
Repeatable Read
 
Serializable
The highest specifies that while one transaction is operating on a database, no other
transactions may make any changes to the data that transaction reads.
SQL-92 isolations levels are stated in terms of three prohibited operation sequences,
called phenomena . These are as follows:
 
Dirty Read. This occurs if one transaction can see the results of the actions of another
transaction before it commits.
 
Non-Repeatable Read (also called Fuzzy Read). This occurs if the results of one transaction
can be modified or deleted by another transaction before it commits.
 
Phantom Read . This occurs if the results of a query in one transaction can be changed by
another transaction before it commits.
The SQL-92 isolation levels are defined in terms of which of these phenomena can
occur for a given isolation level, as shown in Table 4-1 .
Table 4-1: SQL-92 Isolation Levels
Search WWH ::




Custom Search