You work as an Application Developer for Nero Inc. You want to instruct the DBMS to set the
transaction isolation level so that when a user updates a table in the database, other users cannot
read the value at the same time. Which of the following methods will you use to define the
transaction level?
A.
setTransactionIsolation()
B.
isClosed()
C.
getTransactionIsolation()
D.
supportsTransactions()
Explanation:
The setTransactionIsolation() method of the Connection interface takes an integer as a parameter
and sets the transaction isolation level.
There are five levels of transaction isolation levels provided by JDBC 2.0. The higher the transaction
level, the more care is taken to avoid
database conflicts. On the other hand , the higher the level of isolation, the slower the application
executes (due to increased locking
overhead and decreased concurrency between users). The developer must balance the need for
performance with the need for data
consistency when making a decision about what isolation level to use. However, the level that can
actually be supported depends on the
capabilities of the underlying DBMS.
The highest transaction isolation level specifies that if one transaction is operating on a database, no
other transaction can access that part
of the database.
Answer C is incorrect. The getTransactionIsolation() method returns the current isolation mode of
the transaction associated with the
Connection object.
Answer B is incorrect. The isClosed() method of the Connection object returns a Boolean true if the
connection to the database is
closed, and a Boolean false if the database connection is currently open.
Answer D is incorrect. The supportsTransactions() method of the DatabaseMetaData interface is
used to determine whether a given
database supports the use of transactions or not. It returns a Boolean true if the database supports a
transaction and a Boolean false if it does not.
Set the transaction level