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(); 



//Use WSDataSource to get the connection 

Connection conn = ((WSDataSource)datasource).getConnection(connSpec);


See Also

Resource adapter
Unshareable and shareable connections
Data access application programming interface support