If your application runs with a shareable connection that might be shared with other container-managed persistence (CMP) beans within a transaction, it is recommended that you use the WebSphere Application Server extended APIs to get the connection. When you use these APIs, you cannot port your application to other application servers.
You can access an extended API in your JDBC application. Instead of using the DataSource interface, you use the WSDataSource interface. The following code segment illustrates how to get the connection.
import com.ibm.websphere.rsadapter.*; ... // Create a JDBCConnectionSpec and set connection properties. If this connection is shared with the CMP bean, make sure that the isolation level is the same as the isolation level that is mapped by the Access Intent defined on the CMP bean. JDBCConnectionSpec connSpec = WSRRAFactory.createJDBCConnectionSpec(); connSpec.setTransactionIsolation(CONNECTION.TRANSACTION_REPEATABLE_READ); connSpec.setCatalog("DEPT407"); //Use WSDataSource to get the connection Connection conn = ((WSDataSource)datasource).getConnection(connSpec);
Related concepts
Resource adapter
Unshareable and shareable connections
Related reference
Extensions to data access APIs