com.ibm.websphere.rsadapter
Class DataDirectDataStoreHelper

java.lang.Object
  |
  +--com.ibm.websphere.rsadapter.GenericDataStoreHelper
        |
        +--com.ibm.websphere.rsadapter.DataDirectDataStoreHelper
All Implemented Interfaces:
DataStoreHelper, java.io.Serializable
Direct Known Subclasses:
ConnectJDBCDataStoreHelper, SequeLinkDataStoreHelper

public class DataDirectDataStoreHelper
extends GenericDataStoreHelper
implements java.io.Serializable

This is a helper class customized for the dataDirect database. It allows us to plug in data store specific functions. When trying to map an exception, the dataDirect errormap will be searched first then the generic one will be searched.

If you have any special dataDirect requirements, you might want to look into extending this class and overwriting the methods you wish to change.

See Also:
Serialized Form

Fields inherited from class com.ibm.websphere.rsadapter.GenericDataStoreHelper
EOLN, genErrorMap, resBundle
 
Fields inherited from interface com.ibm.websphere.rsadapter.DataStoreHelper
CLOUDSCAPE_HELPER, CLOUDSCAPE_NETWORK_SERVER_HELPER, CONNECTJDBC_HELPER, CUSTOM_HELPER, DATADIRECT_HELPER, DB2_390_HELPER, DB2_390_LOCAL_HELPER, DB2_400_HELPER, DB2_HELPER, DB2_UNIVERSAL_HELPER, GENERIC_HELPER, INFORMIX_HELPER, MSSQL_HELPER, ORACLE_HELPER, POTENTIAL_DEADLOCK, POTENTIAL_LOST_UPDATE, SEQUELINK_HELPER, SYBASE_HELPER, SYBASE11_HELPER, TX_REPEATABLE_READ_FORUPDATE, TX_SERIALIZABLE_FORUPDATE, UPDATE_ON_READONLY, WSCONNECTJDBC_HELPER
 
Constructor Summary
DataDirectDataStoreHelper(java.util.Properties props)
          Constructor, the property is passed in case some info is needed in the future, for now this parameter is not used.
 
Method Summary
 void doConnectionSetup(java.sql.Connection conn)
          This method allows the DataStoreHelper to set any connection properties that are not specified in the default configuration.
 java.lang.Class findMappingClass(java.sql.SQLException e)
          This method returns mapping for a given exception if one is found.
 int getIsolationLevel(com.ibm.websphere.appprofile.accessintent.AccessIntent aIntent)
          This method returns the isolation level given the Intent object.
 java.io.PrintWriter getPrintWriter()
          This method is used to get the printWriter to be used to output jdbc logging when database logging is enabled (e.g.
protected  boolean isDataDirectExp(java.sql.SQLException e)
          This method checks if an exception is a dataDirect exception or a dataDirect-vendor (i.e.
 void setUserDefinedMap(java.util.Map newmap)
          This method is used to add user defined error maps.
 java.lang.String showLockInfo(java.util.Properties props)
          This method returns lock information for MS SQLServer.
 
Methods inherited from class com.ibm.websphere.rsadapter.GenericDataStoreHelper
calcPartitionNumber, doConnectionCleanup, doStatementCleanup, getLockType, getMetaData, getResultSetConcurrency, getResultSetType, getXAExceptionContents, hasLostUpdateOrDeadLockOccurred, isBatchUpdateSupportedWithAccessIntent, isConnectionError, mapException, mapException, modifyXAFlag, processGenericCredentials
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataDirectDataStoreHelper

public DataDirectDataStoreHelper(java.util.Properties props)
Constructor, the property is passed in case some info is needed in the future, for now this parameter is not used.
Parameters:
props - not used here, entry will be ignored
Method Detail

isDataDirectExp

protected boolean isDataDirectExp(java.sql.SQLException e)
This method checks if an exception is a dataDirect exception or a dataDirect-vendor (i.e. sqlserver) one. The method will be used to decide how to map the exception returned. If it a dataDirect exception, we will search through the dataDirect table only
Parameters:
e - SQLException
Returns:
true if exception is a dataDirect only exception false if the exception is a third vendor exception (e.g. sqlserver exception that was thrown through dataDirect driver.

findMappingClass

public final java.lang.Class findMappingClass(java.sql.SQLException e)
This method returns mapping for a given exception if one is found. First the user defined map is searched followed by the predefined dataDirect map. If nothing is found, the search continues in the parent class - GenericHelper. The search is done in the following order:
  1. first the errorCode is searched
  2. then the SQLState.

If a user wants to override the mapping of a specific Exception, they can override this method and either return the same exception class or return null. In the mapexception() which calls this method if the map found is null then the original exception is returned. A user can also cancel the mapping by returning null for that exception map.

Overrides:
findMappingClass in class GenericDataStoreHelper
Parameters:
e - The SQLException we need to find a mapping class for
Returns:
java.lang.Class - The mapped class

getIsolationLevel

public final int getIsolationLevel(com.ibm.websphere.appprofile.accessintent.AccessIntent aIntent)
                            throws javax.resource.ResourceException
This method returns the isolation level given the Intent object. If the intent Object passed is null, the websphere default is returned. The websphere default is dependent on the backend database. In this case it will be TRANSACTION_REPEATABLE_READ If this value is not desired one could override it in a subclass.

AccessType: Optimistic --> map to RC; PessimisticRead --> map to RR

Pessimistic Update : Update Hint Value order is:
greedy nocollision Exclusive
0/1 0/1 0/1

when adding up the combo as an integer, for example:

BTW 7 is an invalid option since you can't have nocollision and exclusive together.

Note:
We don't allow pessimistic_update_random, therefore, this assumption is made when calculation is done

Overrides:
getIsolationLevel in class GenericDataStoreHelper
Parameters:
aIntent - AccessIntent
Returns:
int - An isolation level. The value is based on the isolation level that is defined in the java.sql.Connection.
Throws:
javax.resource.ResourceException -  
See Also:
Intent

doConnectionSetup

public void doConnectionSetup(java.sql.Connection conn)
                       throws java.sql.SQLException
This method allows the DataStoreHelper to set any connection properties that are not specified in the default configuration. Since this is the base class for DataDirect, we delegate to the contained helper. in here only MSSQL, the actual DataDirect connection setup for Type3 and type4 happens in the subclasses DataDirectType3.. and DataDirectType4..
Overrides:
doConnectionSetup in class GenericDataStoreHelper
Parameters:
conn -  
Throws:
java.sql.SQLException -  

setUserDefinedMap

public final void setUserDefinedMap(java.util.Map newmap)
This method is used to add user defined error maps. It is useful when the user wants a slght tweaking of the map. For a comprehensive change it might be advisable to extend this object.
Overrides:
setUserDefinedMap in class GenericDataStoreHelper
Parameters:
newmap - a list of SQL error codes / states and the Exception class

getPrintWriter

public java.io.PrintWriter getPrintWriter()
This method is used to get the printWriter to be used to output jdbc logging when database logging is enabled (e.g. WAS.database=all=enabled). by default, a null is returned and a WAS printWriter is used. Users could overwrite this method to return a different PrintWriter, and it will be used instead of the default.
Overrides:
getPrintWriter in class GenericDataStoreHelper
Returns:
java.io.PrintWriter.

showLockInfo

public final java.lang.String showLockInfo(java.util.Properties props)
                                    throws java.lang.Exception
This method returns lock information for MS SQLServer. We depend on MS SQLServer's mechanism to generate the lock information. MS SQLServer puts this information into a result set. We extract the information from the result set and return it as a String.
Overrides:
showLockInfo in class GenericDataStoreHelper
Parameters:
props - Props should have the following data to establish a connection with MSSQLServer:
  1. user - username that has a DBA authority, default if not specified = "sa"
  2. password - default if not specified =
  3. serverName - server name where MSSQLServer DB resides
  4. portNumber - port where MSSQLServer listener is listening
    Returns:
    Output string with locking info for MSSQLServer.
    Throws:
    java.lang.Exception - Could range from java.io exceptions to javax.sql exceptions since we are running operations against the OS.