Data access portability features



The WAS relational resource adapter (RRA) provides a portability feature that enables applications to access data from different databases without changing the application. In addition, WAS enables you to plug in a data source that is not supported by WebSphere persistence.

The data source must be implemented as either the XADataSource or the ConnectionPoolDataSource, and it must be in compliance with the JDBC 2.x specification.

You can achieve application portability through the following...


DataStoreHelper interface

With the DataStoreHelper interface, each data store platform can plug in its own private data store specific functions that the relational resource adapter run time uses. WAS provides an implementation for each supported JDBC provider.

In addition, the interface also provides a GenericDataStoreHelper class for unsupported data sources to use. You can subclass the GenericDataStoreHelper or other WebSphere provided helpers to support any new data source.

The following code segment shows how a new data store helper is created to add two new error mappings for an unsupported data source.

public class NewDSHelper extends GenericDataStoreHelper
  public NewDSHelper()  
    java.util.Hashtable myErrorMap = null;
    myErrorMap = new java.util.Hashtable(2);
    myErrorMap.put(new Integer(-803), myDuplicateKeyException.class);
    myErrorMap.put(new Integer(-1015), myStaleConnectionException.class);
    myErrorMap.put("S1000", MyTableNotFoundException.class);


WSCallHelper class

Using the WSCallHelper class applications can invoke any JDBC object proprietary methods that are not defined or standard APIs. This helper also enables applications to invoke many non-JDBC object methods.

All methods are static: see Javadoc WSCallHelper in the Javadoc index.

The following code segment illustrates using this helper class (with a DB2 data source)

Connection conn = ds.getConnection();
// get connection attribute
String connectionAttribute =(String) WSCallHelper.jdbcCall(DataSource.class, ds,
 "getConnectionAttribute", null, null);
// setAutoClose to false
conn, "setAutoClose",
new Object[] { new Boolean(false)},
new Class[] { boolean.class });
// get data store helper
DataStoreHelper dshelper = WSCallHelper.getDataStoreHelper(ds);


See Also