WebSphere Application Server Version 6.1 Feature Pack for Web Services
             Operating Systems: AIX, HP-UX, i5/OS, Linux, Solaris, Windows, z/OS

             Personalize the table of contents and search results

Example: Using IBM extended APIs for database connections

Using the WSDataSource extended API, you can code your JDBC application to define connection properties through an object before obtaining a connection. This behavior increases the chances that the application can share a connection with another component, such as a CMP.

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 code with the extended API directly in your JDBC application; instead of using the DataSource interface to get a connection, use the WSDataSource interface. The following code segment illustrates WSDataSource:


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 adapters
Unshareable and shareable connections
Related reference
Extensions to data access APIs
Reference topic    

Terms of Use | Feedback

Last updated: Nov 25, 2008 2:35:59 AM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/rdat_extiapi.html