Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » jdbc » datasource » [javadoc | source]
org.springframework.jdbc.datasource
public class: IsolationLevelDataSourceAdapter [javadoc | source]
java.lang.Object
   org.springframework.jdbc.datasource.DelegatingDataSource
      org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter
         org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter

All Implemented Interfaces:
    DataSource, InitializingBean

Direct Known Subclasses:
    WebSphereDataSourceAdapter

An adapter for a target javax.sql.DataSource , applying the current Spring transaction's isolation level (and potentially specified user credentials) to every getConnection call. Also applies the read-only flag, if specified.

Can be used to proxy a target JNDI DataSource that does not have the desired isolation level (and user credentials) configured. Client code can work with this DataSource as usual, not worrying about such settings.

Inherits the capability to apply specific user credentials from its superclass UserCredentialsDataSourceAdapter ; see the latter's javadoc for details on that functionality (e.g. #setCredentialsForCurrentThread ).

WARNING: This adapter simply calls java.sql.Connection#setTransactionIsolation and/or java.sql.Connection#setReadOnly for every Connection obtained from it. It does, however, not reset those settings; it rather expects the target DataSource to perform such resetting as part of its connection pool handling. Make sure that the target DataSource properly cleans up such transaction state.

Method from org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter Summary:
doGetConnection,   getCurrentIsolationLevel,   getCurrentReadOnlyFlag,   getIsolationLevel,   setIsolationLevel,   setIsolationLevelName
Methods from org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter:
doGetConnection,   getConnection,   getConnection,   removeCredentialsFromCurrentThread,   setCredentialsForCurrentThread,   setPassword,   setUsername
Methods from org.springframework.jdbc.datasource.DelegatingDataSource:
afterPropertiesSet,   getConnection,   getConnection,   getLogWriter,   getLoginTimeout,   getTargetDataSource,   isWrapperFor,   setLogWriter,   setLoginTimeout,   setTargetDataSource,   unwrap
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter Detail:
 protected Connection doGetConnection(String username,
    String password) throws SQLException 
    Applies the current isolation level value and read-only flag to the returned Connection.
 protected Integer getCurrentIsolationLevel() 
    Determine the current isolation level: either the transaction's isolation level or a statically defined isolation level.
 protected Boolean getCurrentReadOnlyFlag() 
    Determine the current read-only flag: by default, the transaction's read-only hint.
 protected Integer getIsolationLevel() 
    Return the statically specified isolation level, or null if none.
 public  void setIsolationLevel(int isolationLevel) 
    Specify the default isolation level to use for Connection retrieval, according to the JDBC java.sql.Connection constants (equivalent to the corresponding Spring org.springframework.transaction.TransactionDefinition constants).

    If not specified, the target DataSource's default will be used. Note that a transaction-specific isolation value will always override any isolation setting specified at the DataSource level.

 public final  void setIsolationLevelName(String constantName) throws IllegalArgumentException 
    Set the default isolation level by the name of the corresponding constant in org.springframework.transaction.TransactionDefinition , e.g. "ISOLATION_SERIALIZABLE".

    If not specified, the target DataSource's default will be used. Note that a transaction-specific isolation value will always override any isolation setting specified at the DataSource level.