Define Isolation.- Isolation ensures one transaction does not interfere with another.
- Isolation helps when there are concurrent transactions.
- In order to set the isolation level for a JDBC transaction, we can use Connection.setTransaction(int level) method.
- There are five levels of transaction isolation which are as follows:
1. JDBC_TRANSACTION_NONE: - A special constant that JDBC driver does not support transactions.
2. JDBC_TRANSACTION_READ_UNCOMMITTED: - Allows looking after the uncommitted changes to the database.
3. JDBC_TRANSACTION_READ_COMMITTED: - The transactions are externally invisible until the transaction is committed. - The dirty reads prevention is possible with this level.
4. JDBC_TRANSACTION_REPEATABLE_READ: - The readable rows retain locks by which another transaction can not change them until the transaction completes. - It disallows dirty reads and non repeatable reads.
5. JDBC_TRANSACTION_SERIALIZABLE: - The tables are locked for the transaction which makes the WHERE conditions not to be changed by other transactions. - This process prevents all database anomalies.
|