类 WebSphereDataSourceAdapter
- java.lang.Object
- org.springframework.jdbc.datasource.DelegatingDataSource
- org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter
- org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter
- org.springframework.jdbc.datasource.WebSphereDataSourceAdapter
- 所有已实现的接口:
Wrapper
,CommonDataSource
,DataSource
,InitializingBean
public class WebSphereDataSourceAdapter extends IsolationLevelDataSourceAdapter
DataSource
implementation that delegates all calls to a WebSphere targetDataSource
, 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
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!- 从以下版本开始:
- 2.0.3
- 作者:
- Juergen Hoeller, Lari Hotari, Ricardo N. Olivieri
- 另请参阅:
com.ibm.websphere.rsadapter.JDBCConnectionSpec
,com.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec)
,TransactionSynchronizationManager.getCurrentTransactionIsolationLevel()
,TransactionSynchronizationManager.isCurrentTransactionReadOnly()
构造器概要
构造器 构造器 说明 WebSphereDataSourceAdapter()
This constructor retrieves the WebSphere JDBC connection spec API, so we can get obtain specific WebSphere Connections using reflection.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Checks that the specified 'targetDataSource' actually is a WebSphere WSDataSource.protected Object
createConnectionSpec(Integer isolationLevel, Boolean readOnlyFlag, String username, String password)
Create a WebSphereJDBCConnectionSpec
object for the given characteristics.protected Connection
doGetConnection(String username, String password)
Builds a WebSphere JDBCConnectionSpec object for the current settings and callsWSDataSource.getConnection(JDBCConnectionSpec)
.从类继承的方法 org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter
getCurrentIsolationLevel, getCurrentReadOnlyFlag, getIsolationLevel, setIsolationLevel, setIsolationLevelName
从类继承的方法 org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter
getConnection, getConnection, removeCredentialsFromCurrentThread, setCatalog, setCredentialsForCurrentThread, setPassword, setSchema, setUsername
从类继承的方法 org.springframework.jdbc.datasource.DelegatingDataSource
getLoginTimeout, getLogWriter, getParentLogger, getTargetDataSource, isWrapperFor, obtainTargetDataSource, setLoginTimeout, setLogWriter, setTargetDataSource, unwrap
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 javax.sql.CommonDataSource
createShardingKeyBuilder
从接口继承的方法 javax.sql.DataSource
createConnectionBuilder
构造器详细资料
WebSphereDataSourceAdapter
public WebSphereDataSourceAdapter()
This constructor retrieves the WebSphere JDBC connection spec API, so we can get obtain specific WebSphere Connections using reflection.
方法详细资料
afterPropertiesSet
public void afterPropertiesSet()
Checks that the specified 'targetDataSource' actually is a WebSphere WSDataSource.- 指定者:
afterPropertiesSet
在接口中InitializingBean
- 覆盖:
afterPropertiesSet
在类中DelegatingDataSource
doGetConnection
protected Connection doGetConnection(@Nullable String username, @Nullable String password) throws SQLException
Builds a WebSphere JDBCConnectionSpec object for the current settings and callsWSDataSource.getConnection(JDBCConnectionSpec)
.- 覆盖:
doGetConnection
在类中IsolationLevelDataSourceAdapter
- 参数:
username
- the username to usepassword
- the password to use- 返回:
- the Connection
- 抛出:
SQLException
- 另请参阅:
createConnectionSpec(java.lang.Integer, java.lang.Boolean, java.lang.String, java.lang.String)
,com.ibm.websphere.rsadapter.WSDataSource#getConnection(com.ibm.websphere.rsadapter.JDBCConnectionSpec)
createConnectionSpec
protected Object createConnectionSpec(@Nullable Integer isolationLevel, @Nullable Boolean readOnlyFlag, @Nullable String username, @Nullable String password) throws SQLException
Create a WebSphereJDBCConnectionSpec
object for the given characteristics.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 (ornull
if none)readOnlyFlag
- the read-only flag to apply (ornull
if none)username
- the username to apply (null
or empty indicates the default)password
- the password to apply (may benull
or empty)- 抛出:
SQLException
- if thrown by JDBCConnectionSpec API methods- 另请参阅:
com.ibm.websphere.rsadapter.JDBCConnectionSpec