com.ibm.websphere.rsadapter
Class OracleDataStoreHelper

java.lang.Object
  |
  +--com.ibm.websphere.rsadapter.GenericDataStoreHelper
        |
        +--com.ibm.websphere.rsadapter.OracleDataStoreHelper
All Implemented Interfaces:
DataStoreHelper, java.io.Serializable

public class OracleDataStoreHelper
extends GenericDataStoreHelper
implements java.io.Serializable

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

If you have any special Oracle 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
OracleDataStoreHelper(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 addNewMap(java.util.Map newmap)
          This method is used to add user defined error maps.
 java.lang.String assembleSqlString(java.lang.String[] blobColumnNames, java.lang.StringBuffer whereClause, java.lang.String[] varValues, java.lang.String tableName)
          examples of parameters // blobColumnNames={"pic"}; // whereClause= "where id = ? and name = ?"; // varValues={"4"}; // tableName= "ITEM"; //return should be: select pic from ITEM wehre id = 4;
 void doSpecialBLobWork(java.sql.ResultSet rset, java.io.InputStream[] data, java.lang.String[] blobColumnNames)
          This is a function to do any special work needed for inserting or updating a blob to work around the oracle problem precondition: the inputStream array is in the same order as the blobColumnNames , so the first entry in the data corresponds to the first entry in the blobnames array no checking for null values is there, assuming null never passed
 void doStatementCleanup(java.sql.PreparedStatement stmt)
          Clean up a statement before it is placed in the cache.
 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.
 int getLockType(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
          This method returns a locktype based on the input AccessIntent update hint value.
 int getResultSetConcurrency(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
          This method returns the resultSet concurrency given the Intent Object.
 java.lang.String getXAExceptionContents(javax.transaction.xa.XAException xae)
          This method will be used to display in the trace file the contents of the XAException.
 java.lang.String hasLostUpdateOrDeadLockOccurred(int isoLevel, boolean loadedForUpdate)
          This method should be called when storing a CMP EntityBean if pessismistic concurrency control is activated.
 boolean isBatchUpdateSupportedWithAccessIntent(com.ibm.websphere.appprofile.accessintent.AccessIntent accessIntent)
          This method is used to determine if Batch is supported with the given accessIntent object.
 int modifyXAFlag(int xaflag)
          This method will be used modify given flag which is passed on the XA start method.
 java.lang.String showLockInfo(java.util.Properties props)
          This method returns lock information for Oracle.
 
Methods inherited from class com.ibm.websphere.rsadapter.GenericDataStoreHelper
calcPartitionNumber, doConnectionCleanup, doConnectionSetup, getMetaData, getPrintWriter, getResultSetType, isConnectionError, mapException, mapException, processGenericCredentials, setUserDefinedMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDataStoreHelper

public OracleDataStoreHelper(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 needed here, entry will be ignored
Method Detail

doStatementCleanup

public void doStatementCleanup(java.sql.PreparedStatement stmt)
                        throws java.sql.SQLException
Clean up a statement before it is placed in the cache. This method is called only for statements which are being cached. It is called only if certain statement properties have changed. See DataStoreHelper.
Overrides:
doStatementCleanup in class GenericDataStoreHelper
Parameters:
stmt - the PreparedStatement.
Throws:
java.sql.SQLException - if an error occurs cleaning up the statement.

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 Oracle 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 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. TRANSACTION_READ_COMMITTED will be returned in all cases except when the access intent is PESSIMISTIC_UPDATE_LOCK_HINT_EXCLUSIVE The websphere default is dependent on the backend database. In this case it will be TRANSACTION_READ_COMMITTED
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

getResultSetConcurrency

public int getResultSetConcurrency(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
                            throws javax.resource.ResourceException
This method returns the resultSet concurrency given the Intent Object.

For Oracle, CONCUR_READ_ONLY & CONCUR_UPDATABLE are the only supported values. CONCUR_READ_ONLY is also the default JDBC value. If this value is not desired one could override it in a subclass.

Overrides:
getResultSetConcurrency in class GenericDataStoreHelper
Parameters:
intent - AccessIntent
Returns:
CONCUR_READ_ONLY or CONCUR_UPDATABLE
Throws:
javax.resource.ResourceException -  
See Also:
AccessIntent

hasLostUpdateOrDeadLockOccurred

public java.lang.String hasLostUpdateOrDeadLockOccurred(int isoLevel,
                                                        boolean loadedForUpdate)
This method should be called when storing a CMP EntityBean if pessismistic concurrency control is activated. This method determines whether a potential lost update or deadlock scenario has occured. If so, this method returns an appropriate message id. Info must get passed on to the bean provider via a warning or something similar so that they make code changes to avoid these potential problems in the future.

pre-conditions

Overrides:
hasLostUpdateOrDeadLockOccurred in class GenericDataStoreHelper
Parameters:
isoLevel - the isolation level used.
loadedForUpdate - true if the CMP EntityBean was loaded for update (eg. FOR UPDATE keywords used on SELECT).
Returns:
String - the message id defined in the GenericDataStoreHelper.java Note that for some DB vendors where the behavior is different this method is over-ridden

showLockInfo

public final java.lang.String showLockInfo(java.util.Properties props)
                                    throws java.lang.Exception
This method returns lock information for Oracle. We depend on Oracle's mechanism to generate the lock information. Oracle 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 Oracle:
  1. user - username that has a DBA authority, default if not specified = null
  2. password - default if non specified is : null
  3. URL - the URL from which connections have to be obtained. e.g jdbc:oracle:thin:@hostname:1521:dbname
    Returns:
    Output string with locking info for Oracle.
    Throws:
    java.lang.Exception - Could range from java.io exceptions to javax.sql exceptions since we are running operations against the OS

addNewMap

public final void addNewMap(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.
Parameters:
newmap - a list of SQL error codes / states and the Exception class

getLockType

public int getLockType(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
This method returns a locktype based on the input AccessIntent update hint value. The locktype is used by the perssitence manager to determine whether this select statement is a normal Select, a Select for Update, Select for Update with RS or RR lock.
Overrides:
getLockType in class GenericDataStoreHelper
Parameters:
intent - An AccessIntent
Returns:
the locktype. The possible values are defined in com.ibm.websphere.rsadaper.WSInteractionSpec:
  • LOCKTYPE_SELECT
  • LOCKTYPE_SELECT_FOR_UPDATE

doSpecialBLobWork

public void doSpecialBLobWork(java.sql.ResultSet rset,
                              java.io.InputStream[] data,
                              java.lang.String[] blobColumnNames)
                       throws com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException
This is a function to do any special work needed for inserting or updating a blob to work around the oracle problem precondition: the inputStream array is in the same order as the blobColumnNames , so the first entry in the data corresponds to the first entry in the blobnames array no checking for null values is there, assuming null never passed
Parameters:
rset - rset: the resultSet containing the blob row to be updated
data - InputStream: the data to be updated into the blob
blobColumnNames - String array that contains the blob names, needed to assemble the sql string e.g. {"col1", "col2"}
Throws:
com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException -  

assembleSqlString

public java.lang.String assembleSqlString(java.lang.String[] blobColumnNames,
                                          java.lang.StringBuffer whereClause,
                                          java.lang.String[] varValues,
                                          java.lang.String tableName)
examples of parameters // blobColumnNames={"pic"}; // whereClause= "where id = ? and name = ?"; // varValues={"4"}; // tableName= "ITEM"; //return should be: select pic from ITEM wehre id = 4;
Parameters:
blobColumnNames - String[]: contains blob column names
whereClause - String: contains the string after where for example: id = ? and name=?
varValues - String array containing the values that should be put in the where cluase ?s. For the example above, if the values are 1 and soloman then the array should be {"1", "soloman"}
tableName - String: table name
Returns:
String: sql string. for the example above, it should be select pic from ITEM where id = 4 and name = soloman

getXAExceptionContents

public java.lang.String getXAExceptionContents(javax.transaction.xa.XAException xae)
This method will be used to display in the trace file the contents of the XAException. Some backend allow for proprietary ways to display the exception contents. This method will be used for that purpose
Overrides:
getXAExceptionContents in class GenericDataStoreHelper
Parameters:
XAException -  

modifyXAFlag

public int modifyXAFlag(int xaflag)
This method will be used modify given flag which is passed on the XA start method. Some databases (Oracle) requires a proprietary flag OracleXAResource.ORATRANSLOOSE. This method will be a no-op for all databases except Oracle
Overrides:
modifyXAFlag in class GenericDataStoreHelper
Parameters:
xaflag -  
Returns:
int The method will return a modified xaflag. in this case the same flag is returned

isBatchUpdateSupportedWithAccessIntent

public boolean isBatchUpdateSupportedWithAccessIntent(com.ibm.websphere.appprofile.accessintent.AccessIntent accessIntent)
This method is used to determine if Batch is supported with the given accessIntent object. there are some cases e.g. occ where some database e.g Oracle doesn't support occ since they don't return the actual number of records updated, rather they return -2 all the time. in those cases, we will not use batchupdate and will ignore the batchupdate setting and use normal update This method will be called indirectly by PMs code before they do the batching
Overrides:
isBatchUpdateSupportedWithAccessIntent in class GenericDataStoreHelper
Parameters:
accessIntent - AccessIntent
Returns:
boolean true if batching is allowd, false otherwise