| java.lang.Object | ||||
| ↳ | org.springframework.jdbc.datasource.DelegatingDataSource | |||
| ↳ | org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter | |||
| ↳ | org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter | |||
| ↳ | org.springframework.jdbc.datasource.WebSphereDataSourceAdapter | |||
DataSource implementation that delegates all calls to a WebSphere target DataSource, typically obtained from JNDI, applying a current isolation level and/or current user credentials to every Connection obtained from it.
Uses IBM-specific API to get a JDBC Connection with a specific isolation
level (and read-only flag) from a WebSphere DataSource
(IBM code example).
Supports the transaction-specific isolation level exposed by
getCurrentTransactionIsolationLevel().
It's also possible to specify a default isolation level, to be applied when the
current Spring-managed transaction does not define a specific isolation level.
Usage example, defining the target DataSource as an inner-bean JNDI lookup (of course, you can link to any WebSphere DataSource through a bean reference):
<bean id="myDataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
<property name="targetDataSource">
<bean class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jdbc/myds"/>
</bean>
</property>
</bean>
Thanks to Ricardo Olivieri for submitting the original implementation
of this approach!
getCurrentTransactionIsolationLevel()isCurrentTransactionReadOnly()| Fields | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| logger | |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
This constructor retrieves the WebSphere JDBC connection spec API,
so we can get obtain specific WebSphere Connections using reflection.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Checks that the specified 'targetDataSource' actually is
a WebSphere WSDataSource.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Create a WebSphere
JDBCConnectionSpec object for the given charateristics. | |||||||||||
Builds a WebSphere JDBCConnectionSpec object for the current settings
and calls
WSDataSource.getConnection(JDBCConnectionSpec). | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter
| |||||||||||
From class
org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter
| |||||||||||
From class
org.springframework.jdbc.datasource.DelegatingDataSource
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.sql.Wrapper
| |||||||||||
From interface
javax.sql.CommonDataSource
| |||||||||||
From interface
javax.sql.DataSource
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
This constructor retrieves the WebSphere JDBC connection spec API, so we can get obtain specific WebSphere Connections using reflection.
Checks that the specified 'targetDataSource' actually is a WebSphere WSDataSource.
Create a WebSphere JDBCConnectionSpec object for the given charateristics.
The default implementation uses reflection to apply the given settings. Can be overridden in subclasses to customize the JDBCConnectionSpec object (JDBCConnectionSpec javadoc; IBM developerWorks article).
| isolationLevel | the isolation level to apply (or null if none) |
|---|---|
| readOnlyFlag | the read-only flag to apply (or null if none) |
| username | the username to apply (null or empty indicates the default) |
| password | the password to apply (may be null or empty) |
| SQLException | if thrown by JDBCConnectionSpec API methods |
|---|
Builds a WebSphere JDBCConnectionSpec object for the current settings
and calls WSDataSource.getConnection(JDBCConnectionSpec).
| username | the username to use |
|---|---|
| password | the password to use |
| SQLException |
|---|
createConnectionSpec(Integer, Boolean, String, String)