These interfaces work with the relational resource adapter (RRA) to make database-specific functions operable on connections between the application server and that database.
In other words, your applications can access data from different databases, and use functions that are specific to the database, without any code changes. Additionally, WebSphere® Application Server enables you to plug in a data source that is not supported by WebSphere persistence. However, the data source must be implemented as either the XADataSource type or the ConnectionPoolDataSource type, and it must be in compliance with the JDBC 2.x specification.
You can achieve application portability through the following:
The interface also provides a GenericDataStoreHelper class for unsupported data sources to use. You can subclass the GenericDataStoreHelper class or other WebSphere provided helpers to support any new data source.
For more information, see the API documentation DataStoreHelper topic (as listed in the API documentation index).
The following code segment shows how a new data store helper is created to add new error mappings for an unsupported data source.
public class NewDSHelper extends GenericDataStoreHelper { public NewDSHelper(java.util.Properties dataStoreHelperProperties) { super(dataStoreHelperProperties); java.util.Hashtable myErrorMap = null; myErrorMap = new java.util.Hashtable(); myErrorMap.put(new Integer(-803), myDuplicateKeyException.class); myErrorMap.put(new Integer(-1015), myStaleConnectionException.class); myErrorMap.put("S1000", MyTableNotFoundException.class); setUserDefinedMap(myErrorMap); ... } }
By using the static jdbcCall() method, you can invoke vendor-specific, nonstandard JDBC methods on your JDBC objects. (For more information, see the API documentation WSCallHelper topic.) The following code segment illustrates using this method 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 WSCallHelper.jdbcCall(java.sql.Connection.class, conn, "setAutoClose", new Object[] { new Boolean(false)}, new Class[] { boolean.class }); // get data store helper DataStoreHelper dshelper = WSCallHelper.getDataStoreHelper(ds);
Use this method to exploit the nonstandard JDBC classes that some database vendors provide. These classes contain methods that require vendors' proprietary JDBC objects to be passed as parameters.
oracle.sql.ArrayDescriptor ArrayDescriptor.createDescriptor(java.lang.String, java.sql.Connection) oracle.sql.ARRAY new ARRAY(oracle.sql.ArrayDescriptor, java.sql.Connection, java.lang.Object) oracle.xml.sql.query.OracleXMLQuery(java.sql.Connection, java.lang.String) oracle.sql.BLOB.createTemporary(java.sql.Connection, boolean, int) oracle.sql.CLOB.createTemporary(java.sql.Connection, boolean, int) oracle.xdb.XMLType.createXML(java.sql.Connection, java.lang.String)
XMLType poXML = (XMLType)(WSCallHelper.jdbcPass(XMLType.class, "createXML", new Object[]{conn,poString}, new Class[]{java.sql.Connection.class, java.lang.String.class}, new int[]{WSCallHelper.CONNECTION,WSCallHelper.IGNORE}));
Because of these potential problems, WebSphere Application Server strictly controls which methods are allowed to be invoked using the jdbcPass() method support. If you require support for a method that is not listed previously in this document, contact WebSphere Application Server Support with information on the method you require.