Apply the WebSphere extension, GenericDataStoreHelper class, to create your own data store helper for data sources that the application server does not support. With this helper class, your JDBC configuration can use database-specific functions during transactions.
package com.ibm.websphere.examples.adapter; import java.sql.SQLException; import javax.resource.ResourceException; import com.ibm.websphere.appprofile.accessintent.AccessIntent; import com.ibm.websphere.ce.cm.*; import com.ibm.websphere.rsadapter.WSInteractionSpec; /** * Example DataStoreHelper class, demonstrating how to create a user-defined DataStoreHelper. * The implementation for each method is provided only as an example. More detail is probably * required for any custom DataStoreHelper that is created for use by a real application. * In this example, we will override the doStatementCleanup(),getIsolationLevel(), and set userDefined * exception map. */ public class ExampleDataStoreHelper extends com.ibm.websphere.rsadapter.GenericDataStoreHelper { public ExampleDataStoreHelper(java.util.Properties props) { super(props); // Update the DataStoreHelperMetaData values for this helper. getMetaData().setGetTypeMapSupport(false); // Update the exception mappings for this helper. java.util.Map xMap = new java.util.HashMap(); // Add an Error Code mapping to StaleConnectionException. xMap.put(new Integer(2310), StaleConnectionException.class); // Add an Error Code mapping to DuplicateKeyException. xMap.put(new Integer(1062), DuplicateKeyException.class); // Add a SQL State mapping to the user-defined ColumnNotFoundException xMap.put("S0022", ColumnNotFoundException.class); // Undo an inherited StaleConnection SQL State mapping. xMap.put("S1000", Void.class); setUserDefinedMap(xMap); // If you are extending a helper class, it is // normally not necessary to issue 'getMetaData().setHelperType(...)' // because your custom helper will inherit the helper type from its // parent class. } public void doStatementCleanup(java.sql.PreparedStatement stmt) throws SQLException { // Clean up the statement so it may be cached and reused. stmt.setCursorName(""); stmt.setEscapeProcessing(true); stmt.setFetchDirection(java.sql.ResultSet.FETCH_FORWARD); stmt.setMaxFieldSize(0); stmt.setMaxRows(0); stmt.setQueryTimeout(0); } public int getIsolationLevel(AccessIntent intent) throws ResourceException { // Determine an isolation level based on the AccessIntent. // set WebSphere default isolation level to TRANSACTION_SERIALIZABLE. if (intent == null) return java.sql.Connection.TRANSACTION_SERIALIZABLE; return intent.getConcurrencyControl() == AccessIntent.CONCURRENCY_CONTROL_OPTIMISTIC ? java.sql.Connection.TRANSACTION_READ_COMMITTED : java.sql.Connection.TRANSACTION_REPEATABLE_READ; } public int getLockType(AccessIntent intent) { if ( intent.getConcurrencyControl() == AccessIntent.CONCURRENCY_CONTROL_PESSIMISTIC) { if ( intent.getAccessType() == AccessIntent.ACCESS_TYPE_READ ) { return WSInteractionSpec.LOCKTYPE_SELECT; } else { return WSInteractionSpec.LOCKTYPE_SELECT_FOR_UPDATE; } } return WSInteractionSpec.LOCKTYPE_SELECT; } }
package com.ibm.websphere.examples.adapter; import java.sql.SQLException; import com.ibm.websphere.ce.cm.PortableSQLException; /** * Example PortableSQLException subclass, which demonstrates how to create a user-defined * exception for exception mapping. */ public class ColumnNotFoundException extends PortableSQLException { public ColumnNotFoundException(SQLException sqlX) { super(sqlX); } }
set CLASSPATH=%CLASSPATH%;app_server_root\lib\j2ee.jar;app_server_root\lib\rsaexternals.jar;app_server_root\lib\utils.jar
set CLASSPATH=%CLASSPATH%;app_server_root\lib\j2ee.jar;app_server_root\lib\rshelpers.jar;app_server_root\plugins\com.ibm.ws.runtime_version.jar
set CLASSPATH=$CLASSPATH:app_server_root/lib/j2ee.jar:app_server_root/lib/rsaexternals.jar:app_server_root/lib/utils.jar
set CLASSPATH=$CLASSPATH:app_server_root/lib/j2ee.jar:app_server_root/lib/rshelpers.jar:app_server_root/plugins/com.ibm.ws.runtime_version.jar
C:\javac your_directory\*.java
C:\Java> jar cf myFile.jar *.classFor more information on using the javac compiler go to the website for the Java compiler at Sun Microsystems.
c:\myFile.jar
In this information ...Related concepts
| IBM Redbooks, demos, education, and more(Index) Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience. This feature requires Internet access. Most of the following links will take you to information that is not part of the formal product documentation and is provided "as is." Some of these links go to non-IBM Web sites and are provided for your convenience only and do not in any manner serve as an endorsement by IBM of those Web sites, the material thereon, or the owner thereof. |