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

OracleDataStoreHelper is a DataStoreHelper implementation customized for the Oracle database. When mapping a SQLException, the SQLException mappings from the OracleDataStoreHelper are searched first, and subsequently, if no match is found, the SQLException mappings from the GenericDataStoreHelper are searched. If you have additional requirements on Oracle consider subclassing this implementation.

SQLException mappings specific to the OracleDataStoreHelper are the following:

Error Code PortableSQLException subclass
1 DuplicateKeyException.class
28 StaleConnectionException.class
1012 StaleConnectionException.class
1014 StaleConnectionException.class
1033 StaleConnectionException.class
1034 StaleConnectionException.class
1035 StaleConnectionException.class
1089 StaleConnectionException.class
1090 StaleConnectionException.class
1092 StaleConnectionException.class
3113 StaleConnectionException.class
3114 StaleConnectionException.class
12541 StaleConnectionException.class
12560 StaleConnectionException.class
12571 StaleConnectionException.class
17002 StaleConnectionException.class
17008 StaleConnectionException.class
17009 StaleConnectionException.class
17410 StaleConnectionException.class
17401 StaleConnectionException.class

See Also:
Serialized Form

Field Summary
 
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)
          This OracleDataStoreHelper constructor creates a new OracleDataStoreHelper based on the DataStoreHelper properties provided.
 
Method Summary
 void addNewMap(java.util.Map newmap)
          Deprecated. Use setUserDefinedMap instead.
 java.lang.String assembleSqlString(java.lang.String[] blobColumnNames, java.lang.StringBuffer whereClause, java.lang.String[] varValues, java.lang.String tableName)
          Deprecated.  
 boolean doConnectionCleanup(java.sql.Connection conn)
          This method is used to clean up a connection before it is returned to the connection pool for later reuse.
 void doSpecialBLobWork(java.sql.ResultSet rset, java.io.InputStream[] data, java.lang.String[] blobColumnNames)
          Deprecated.  
 void doStatementCleanup(java.sql.PreparedStatement stmt)
          This method cleans up a statement before the statement is returned to the statement cache.
 java.lang.Class findMappingClass(java.sql.SQLException e)
          This method locates the com.ibm.websphere.ce.cm.PortableSQLException subclass corresponding to the specified SQLException, as defined by the OracleDataStoreHelper, GenericDataStoreHelper, and user-defined SQLException maps.
 int getIsolationLevel(com.ibm.websphere.appprofile.accessintent.AccessIntent aIntent)
          This method determines the transaction isolation level based on the specified AccessIntent.
 int getLockType(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
          This method returns a lock type constant based on the update hint value of the specified AccessIntent.
 int getResultSetConcurrency(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
          This method determines the result set concurrency based on the specified AccessIntent.
 java.lang.String getXAExceptionContents(javax.transaction.xa.XAException xae)
          This method provides a plug-in point for providing meaningful logging information for an XAException.
 java.lang.String hasLostUpdateOrDeadLockOccurred(int isoLevel, boolean loadedForUpdate)
          This method is invoked when storing a CMP EntityBean if pessimistic concurrency control is activated.
 boolean isBatchUpdateSupportedWithAccessIntent(com.ibm.websphere.appprofile.accessintent.AccessIntent accessIntent)
          This method is used to determine if CMP Entity Beans can support batch updates with the given AccessIntent.
 int modifyXAFlag(int xaflag)
          This method is used only when the transactionBranchesLooselyCoupled custom DataSource property is set to true.
 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, doConnectionSetup, getMetaData, getPrintWriter, getResultSetType, isConnectionError, mapException, mapException, processGenericCredentials, processSQL, processSQL, 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)

This OracleDataStoreHelper constructor creates a new OracleDataStoreHelper based on the DataStoreHelper properties provided.

The DataStoreHelper properties for OracleDataStoreHelper include a property, dataSourceClass, set to the Oracle JDBC driver's DataSource implementation class name.

Parameters:
props - DataStoreHelper properties.
Method Detail

doStatementCleanup

public void doStatementCleanup(java.sql.PreparedStatement stmt)
                        throws java.sql.SQLException

This method cleans up a statement before the statement is returned to the statement cache. This method is called only for statements that will be cached. It is called only if at least one of the following statement properties has changed,

  • cursorName
  • escapeProcessing
  • fetchDirection
  • maxFieldSize
  • maxRows
  • queryTimeout

OracleDataStoreHelper resets all of the statement properties listed above except for the cursorName property.

The following operations do not need to be included in the statement cleanup since they are automatically performed by WebSphere when caching statements,

  • setFetchSize(0)
  • clearParameters()
  • clearWarnings()

A helper class implementing this method may choose to do additional cleanup for the statement. However, this should never include closing the statement, since the statement is intended to be cached.

Specified by:
doStatementCleanup in interface 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 locates the com.ibm.websphere.ce.cm.PortableSQLException subclass corresponding to the specified SQLException, as defined by the OracleDataStoreHelper, GenericDataStoreHelper, and user-defined SQLException maps. Precedence and related details of SQLException mapping are described on the DataStoreHelper.setUserDefinedMap method.

Overriding this method is one of three options you have for modifying SQLException mapping. The other two options are overriding the mapException method and invoking the setUserDefinedMap method to add a user-defined SQLException map.

Overrides:
findMappingClass in class GenericDataStoreHelper
Parameters:
e - The SQLException for which to locate a com.ibm.websphere.ce.cm.PortableSQLException subclass.
Returns:
The com.ibm.websphere.ce.cm.PortableSQLException subclass matching the SQLException, or null if no match was found.
See Also:
SQLException, com.ibm.websphere.ce.cm.PortableSQLException.

getIsolationLevel

public int getIsolationLevel(com.ibm.websphere.appprofile.accessintent.AccessIntent aIntent)
                      throws javax.resource.ResourceException
This method determines the transaction isolation level based on the specified AccessIntent. If the AccessIntent parameter is null, a default value is returned that is appropriate for the database backend. The default transaction isolation level for OracleDataStoreHelper is Connection.TRANSACTION_READ_COMMITTED.

In the case where an AccessIntent is specified, OracleDataStoreHelper computes the transation isolation level from the following table based on the pessimistic update lock hint.

pessimistic update lock hint transaction isolation level
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_NONE
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_WEAKEST_LOCK_AT_LOAD
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_NOCOLLISION
Connection.TRANSACTION_READ_COMMITTED
AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_EXCLUSIVE Connection.TRANSACTION_SERIALIZABLE

Specified by:
getIsolationLevel in interface DataStoreHelper
Overrides:
getIsolationLevel in class GenericDataStoreHelper
Parameters:
aIntent - An AccessIntent
Returns:
A transaction isolation level appropriate for the specified AccessIntent.
Throws:
javax.resource.ResourceException - If a transaction isolation level cannot be determined from the AccessIntent.
See Also:
AccessIntent, Connection

getResultSetConcurrency

public int getResultSetConcurrency(com.ibm.websphere.appprofile.accessintent.AccessIntent intent)
                            throws javax.resource.ResourceException
This method determines the result set concurrency based on the specified AccessIntent. OracleDataStoreHelper returns java.sql.ResultSet.CONCUR_UPDATABLE if the access type of the AccessIntent is AccessIntent.ACCESS_TYPE_UPDATE, and otherwise java.sql.ResultSet.CONCUR_READ_ONLY.

Specified by:
getResultSetConcurrency in interface DataStoreHelper
Overrides:
getResultSetConcurrency in class GenericDataStoreHelper
Parameters:
intent - An AccessIntent.
Returns:
A result set concurrency constant defined on java.sql.ResultSet.
Throws:
javax.resource.ResourceException - If a result set concurrency cannot be determined from the AccessIntent.
See Also:
AccessIntent, ResultSet

hasLostUpdateOrDeadLockOccurred

public java.lang.String hasLostUpdateOrDeadLockOccurred(int isoLevel,
                                                        boolean loadedForUpdate)
This method is invoked when storing a CMP EntityBean if pessimistic concurrency control is activated. This method determines whether a potential lost update or deadlock scenario has occurred. If so, this method returns an appropriate message id. This information is passed on to the bean provider to provide notification that code changes are needed to avoid potential problems.

pre-conditions

  • pessimistic concurrency control is being used
  • getAutoCommit() on the connection returns false

Specified by:
hasLostUpdateOrDeadLockOccurred in interface DataStoreHelper
Overrides:
hasLostUpdateOrDeadLockOccurred in class GenericDataStoreHelper
Parameters:
isoLevel - the transaction isolation level used.
loadedForUpdate - true if the CMP EntityBean was loaded for update (eg. FOR UPDATE keywords used on SELECT), otherwise false.
Returns:
One of the following
  1. DataStoreHelper.POTENTIAL_LOST_UPDATE
  2. DataStoreHelper.UPDATE_ON_READONLY
  3. DataStoreHelper.POTENTIAL_DEADLOCK

showLockInfo

public final java.lang.String showLockInfo(java.util.Properties props)
                                    throws java.lang.Exception
This method returns lock information for Oracle. The props parameter may include the following properties:

  1. user - a user name that has a DBA authority. If not specified, a default value of null is used.
  2. password - the password corresponding to the user name. If not specified, a default value of null is used.
  3. URL - the Oracle URL from which JDBC connections are obtained. For example, jdbc:oracle:thin:@hostname:1521:dbname

Overrides:
showLockInfo in class GenericDataStoreHelper
Parameters:
props - properties containing information needed to connect to the database.
Returns:
the lock information for Oracle.
Throws:
java.lang.Exception - if an error occurs while collecting the lock information.

addNewMap

public final void addNewMap(java.util.Map newmap)
Deprecated. Use setUserDefinedMap instead.

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 lock type constant based on the update hint value of the specified AccessIntent. The lock type is used by the persistence manager to determine which locking hints are used on a SELECT statement.

OracleDataStoreHelper returns WSInteractionSpec.LOCKTYPE_SELECT_FOR_UPDATE if the AccessIntent is null or if all of the following are true:

  1. The access type of the AccessIntent is AccessIntent.ACCESS_TYPE_UPDATE.
  2. The concurrency control of the AccessIntent is AccessIntent.CONCURRENCY_CONTROL_PESSIMISTIC.
  3. The pessimistic update lock hint of the AccessIntent is AccessIntent.PESSIMISTIC_UPDATE_LOCK_HINT_NOCOLLISION.

In all other cases, WSInteractionSpec.LOCKTYPE_SELECT is returned.

Specified by:
getLockType in interface DataStoreHelper
Overrides:
getLockType in class GenericDataStoreHelper
Parameters:
intent - An AccessIntent
Returns:
the lock type constant. Valid values are defined in com.ibm.websphere.rsadaper.WSInteractionSpec:
  • LOCKTYPE_SELECT
  • LOCKTYPE_SELECT_FOR_UPDATE
See Also:
AccessIntent, com.ibm.websphere.rsadaper.WSInteractionSpec

doSpecialBLobWork

public void doSpecialBLobWork(java.sql.ResultSet rset,
                              java.io.InputStream[] data,
                              java.lang.String[] blobColumnNames)
                       throws com.ibm.ws.rsadapter.exceptions.DataStoreAdapterException
Deprecated.  

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)
Deprecated.  

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 provides a plug-in point for providing meaningful logging information for an XAException. The information can include details of the original exception that caused the XAException, if applicable. WebSphere uses this method to obtain trace information for XAExceptions to include in WebSphere trace.

Specified by:
getXAExceptionContents in interface DataStoreHelper
Overrides:
javax.transaction.xa.XAException)">getXAExceptionContents in class GenericDataStoreHelper
Parameters:
xae - the XAException.
Returns:
detailed information about the XAException, for inclusion in a WebSphere trace.
Since:
WAS 5.0.2
See Also:
XAException

modifyXAFlag

public int modifyXAFlag(int xaflag)

This method is used only when the transactionBranchesLooselyCoupled custom DataSource property is set to true. This method modifies the given XA start flag, adding the proprietary Oracle flag, OracleXAResource.ORATRANSLOOSE.

Specified by:
modifyXAFlag in interface DataStoreHelper
Overrides:
modifyXAFlag in class GenericDataStoreHelper
Parameters:
xaflag - The XA start flag to modify.
Returns:
The modified XA start flag.
Since:
WAS 5.0.1
See Also:
XAResource

isBatchUpdateSupportedWithAccessIntent

public boolean isBatchUpdateSupportedWithAccessIntent(com.ibm.websphere.appprofile.accessintent.AccessIntent accessIntent)
This method is used to determine if CMP Entity Beans can support batch updates with the given AccessIntent. There are some AccessIntents (for example, WebSphere Optimistic Concurrency Control intent) for which some databases are not always capable of determining the number of updated rows. This prevents CMP Entity Beans from being able to support batch updates. In such cases, this method must return false. OracleDataStoreHelper returns false if the concurrency control of the AccessIntent is AccessIntent.CONCURRENCY_CONTROL_OPTIMISTIC, and otherwise returns true.

Specified by:
isBatchUpdateSupportedWithAccessIntent in interface DataStoreHelper
Overrides:
isBatchUpdateSupportedWithAccessIntent in class GenericDataStoreHelper
Parameters:
accessIntent - AccessIntent
Returns:
boolean true if batching is allowed with the given AccessIntent, otherwise false.
Since:
WAS 5.0.2
See Also:
AccessIntent

doConnectionCleanup

public boolean doConnectionCleanup(java.sql.Connection conn)
                            throws java.sql.SQLException

This method is used to clean up a connection before it is returned to the connection pool for later reuse. WebSphere automatically resets all standard connection properties (fields for which getters and setters are defined on java.sql.Connection). This method may be used to reset other properties proprietary to a specific JDBC driver/database and do whatever else is necessary to prepare the connection for reuse.

A DataStoreHelper is permitted to use the provided connection to create and execute statements for the purpose of cleaning up the connection. Any statements created within the doConnectionCleanup method must be explicitly closed within the doConnectionCleanup method. The doConnectionCleanup method must never close the connection being cleaned up.

If any standard connection properties are modified in this method, a value of true must be returned, indicating to WebSphere that at least one standard connection property was modified. A value of false is returned only if no standard connection properties were modified.

Oracle does not allow starting an XA transaction with autocommit set to true. Therefore, this method resets the value of AutoCommit to false if the DataSource used is an javax.sql.XADataSource.

Specified by:
doConnectionCleanup in interface DataStoreHelper
Overrides:
doConnectionCleanup in class GenericDataStoreHelper
Parameters:
conn - the connection to attempt to cleanup.
Returns:
true if any standard connection property was modified, otherwise false.
Throws:
java.sql.SQLException - If an error occurs while cleaning up the connection.
See Also:
Connection


 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.