open class WebSphereDataSourceAdapter : IsolationLevelDataSourceAdapter
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 org.springframework.transaction.support.TransactionSynchronizationManager#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!
Author
Juergen Hoeller
Author
Lari Hotari
Author
Ricardo N. Olivieri
Since
2.0.3
See Also
com.ibm.websphere.rsadapter.JDBCConnectionSpeccom.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec)org.springframework.transaction.support.TransactionSynchronizationManager#getCurrentTransactionIsolationLevel()org.springframework.transaction.support.TransactionSynchronizationManager#isCurrentTransactionReadOnly()
WebSphereDataSourceAdapter()
This constructor retrieves the WebSphere JDBC connection spec API, so we can get obtain specific WebSphere Connections using reflection. |
open fun afterPropertiesSet(): Unit
Checks that the specified 'targetDataSource' actually is a WebSphere WSDataSource. |
open fun setIsolationLevel(isolationLevel: Int): Unit
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. |
|
fun setIsolationLevelName(constantName: String): Unit
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. |