Wednesday, August 13, 2008

Setting the JDBC Transaction Isolation Level in TDI

As the JDBC Transaction Isolation needs to be set in the client side, I asked my Norwegian friends how to do it. As always, Eddie had the answer:

So you should have this option from TDI:

myJDBConnector.getConnector().getConnection().setTransactionIsolation( desiredLevel_int );


The Connection JavaDocs have this to say:


setTransactionIsolation
public void setTransactionIsolation(int level)
throws SQLException
Attempts to change the transaction isolation level for this Connection object to the one given. The constants defined in the interface Connection are the possible transaction isolation levels.
Note: If this method is called during a transaction, the result is implementation-defined.
Parameters:
level - one of the following Connection constants: Connection.TRANSACTION_READ_UNCOMMITTED, Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_REPEATABLE_READ, or Connection.TRANSACTION_SERIALIZABLE. (Note that Connection.TRANSACTION_NONE cannot be used because it specifies that transactions are not supported.)

Throws:
SQLException - if a database access error occurs or the given parameter is not one of the Connection constants
See Also:
DatabaseMetaData.supportsTransactionIsolationLevel(int), getTransactionIsolation()
You will need to do this for each JDBC Connector with its own connection.