Example: Access data using IBM extended APIs for connections
For applications that run with a shareable connection that might be shared with other CMP beans within a transaction, IBM recommends using the WAS extended APIs to get the connection. Note that when you use these APIs, you cannot port your application to other appservers.
Instead of using the DataSource interface, you can 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);
See AlsoResource adapter
Unshareable and shareable connections
Data access application programming interface support