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. and/or
java. 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.
setIsolationLevel, setIsolationLevelName, setUsername, setPassword
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Map | constants
Map of constant names to constant values for the isolation constants
defined in |
| private Integer |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected Connection | doGetConnection(String
the username to use username, String the password to use password)Overrides org. |
| protected Integer | Returns: the current isolation level, ornull if noneDetermine the current isolation level: either the transaction's isolation level or a statically defined isolation level. |
| protected Boolean | Returns: whether there is a read-only hint for the current scopeDetermine the current read-only flag: by default, the transaction's read-only hint. |
| protected Integer | |
| public void | setIsolationLevel(int isolationLevel)
Specify the default isolation level to use for Connection retrieval,
according to the JDBC |
| public final void | setIsolationLevelName(String
name of the constant constantName)Set the default isolation level by the name of the corresponding constant
in |
| constants | back to summary |
|---|---|
| pack-priv static final Map<String, Integer> constants Map of constant names to constant values for the isolation constants
defined in | |
| isolationLevel | back to summary |
|---|---|
| private Integer isolationLevel
| |
| IsolationLevelDataSourceAdapter | back to summary |
|---|---|
| public IsolationLevelDataSourceAdapter() | |
| doGetConnection | back to summary |
|---|---|
| protected Connection doGetConnection(String username, String password) throws SQLException Overrides org. Applies the current isolation level value and read-only flag to the returned Connection.
| |
| getCurrentIsolationLevel | back to summary |
|---|---|
| protected Integer getCurrentIsolationLevel() Determine the current isolation level: either the transaction's isolation level or a statically defined isolation level.
| |
| getCurrentReadOnlyFlag | back to summary |
|---|---|
| protected Boolean getCurrentReadOnlyFlag() Determine the current read-only flag: by default, the transaction's read-only hint.
| |
| getIsolationLevel | back to summary |
|---|---|
| protected Integer getIsolationLevel() Return the statically specified isolation level,
or
| |
| setIsolationLevelName | back to summary |
|---|---|
| public final void setIsolationLevelName(String constantName) throws IllegalArgumentException Set the default isolation level by the name of the corresponding constant
in 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.
| |