public abstract class BaseJDBCHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean | autoFlush
This is the default value of the auto flush parameter which determines whether the EJB container requires to be flushed before executing a JDBC SQL statement.
|
protected static java.lang.String | CONTENT_DS
This is the content data source reference.
|
static java.lang.String | COPYRIGHT
IBM copyright notice field.
|
protected static java.lang.String | DATASOURCE
This is the key for retrieving the data source value.
|
protected static java.util.HashMap | dataSourceConfigData
This is the configuration data associated with the data source.
|
static java.lang.String | DB_AS400
For IBM internal use only.
|
static java.lang.String | DB_DB2
This is a constant that is used by the configurator bean to indicate the target database is IBM UDB for the distributed platforms.
|
static java.lang.String | DB_DB2_390
This is a constant that is used by the configurator bean to indicate the target database is IBM UDB for 390.
|
static java.lang.String | DB_DB2J
This is a constant that is used by the configurator bean to indicate the target database is Apache Derby.
|
static java.lang.String | DB_ORACLE
This is a constant that is used by the configurator bean to indicate the target database is Oracle.
|
protected static java.lang.String | DBTYPE
This is the key for retrieving the data base type value.
|
protected static java.util.HashMap | dsKeys
This is the datasource key defined in dataaccess.xml
|
protected static java.lang.String | ISDB2_390
This is the key used to check for 390 database.
|
protected javax.ejb.SessionContext | mySessionCtx
This is the session context for the session bean.
|
protected static java.lang.String | TRANSACTIONAL_DS
This is the transactional data source reference.
|
Constructor and Description |
---|
BaseJDBCHelper()
This is the default constructor for this class.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String | buildCommaSeparatedWhereClause(int length)
This method builds common separated list of question marks based on the length specified.
|
protected void | closeConnection()
This method closes the opened database connection associated with the object.
|
protected static java.util.Hashtable | convertFirstRowToHashtable(java.sql.ResultSet aResultSet)
This method converts the first element of the specified result set into a Hashtable.
|
static java.util.Vector | convertResultSetToTable(java.sql.ResultSet rs)
This method converts the records found in the result set to a Vector of Vectors.
|
protected static java.lang.String | convertRowFromHashtable(java.util.Hashtable aHashtable)
This method converts the row representation Hashtable that was created by the convertFirstRowToHashtable() into an UPDATE SQL statement to update the row with the new values found in the Hashtable.
|
protected void | debugInitConnection(java.lang.String dataSourceName, java.lang.String userId, java.lang.String pswd)
This method does not perform any operations.
|
protected int | executeOptimisticDelete(java.sql.PreparedStatement aPreparedOptimisticDeleteStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo)
This method executes a prepared optimistic delete statement by calling the executeUpdate method.
|
protected int | executeOptimisticInsert(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, int aOptCounterParameterIndex)
This method executes a prepared optimistic insert statement by calling the executeUpdate method.
|
protected java.sql.ResultSet | executeOptimisticSelect(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo)
This method executes a prepared optimistic select statement by calling the executeQuery method.
|
protected int | executeOptimisticUpdate(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo)
This method executes a prepared optimistic update statement by calling the executeUpdate method.
|
protected int | executeOptimisticUpdateWithIncrementDecrement(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo, java.lang.String astrTableName, java.lang.String astrWhereClause, java.lang.Object[] aWhereClauseParameters, com.ibm.ivj.ejb.runtime.AbstractEntityAccessBean aAbstractEntityAccessBean)
This method calls the executeOptimisticUpdate(PreparedStatement,Object,OptCounterInfo) method.
|
protected java.sql.ResultSet | executeQuery(java.sql.PreparedStatement stmt, boolean bFlush)
This method executes the prepared statement and returns the result set of the execution.
|
protected int | executeUpdate(java.sql.PreparedStatement stmt, boolean bFlush)
This method executes the prepared statement and returns the number of records that were updated as a result.
|
void | flush()
This method writes the outstanding data changes to the database transaction log.
|
protected java.sql.CallableStatement | getCallableStatement(java.lang.String sqlStatement)
This method creates a callable statement that is associated with the JDBC connection of the object.
|
static java.lang.String | getCharacterStreamFromResultSet(java.sql.ResultSet rs, int nColumn)
This method returns the String value of the specified column in the result set.
|
protected java.sql.Connection | getConnection()
This method returns a connection from the data source that is specified on the deployment configuration of the configurator bean.
|
static javax.sql.DataSource | getDataSource()
This method returns the data source that is associated with the application.
|
static javax.sql.DataSource | getDataSource(java.lang.String astrDSKey)
This method returns the data source that is associated with the application for a given data source key.
|
static java.lang.String | getInQueryClause(int nParameters)
This method returns a parameterized SQL IN clause (for example, " IN(?,?)") or equals clause ("=? ") when nParameters is one.
|
static java.lang.Object | getObject(java.sql.ResultSet aResultSet, int aColumnIndex)
This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
|
static java.lang.Object | getObject(java.sql.ResultSet aResultSet, int aColumnIndex, int aColumnType)
This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
|
static java.lang.Object | getObject(java.sql.ResultSet aResultSet, int aColumnIndex, java.sql.ResultSetMetaData aResultSetMetaData)
This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
|
protected java.sql.PreparedStatement | getPreparedStatement(java.lang.String sqlStatement)
This method returns a prepared statement that is associated with the established JDBC connection that is created by a getConnection() or makeConnection() method call.
|
protected java.sql.PreparedStatement | getPreparedStatement(java.lang.String sqlStatement, int resultSetType, int resultSetConcurrency)
This method returns a prepared statement that is associated with the established JDBC connection that is created by the getConnection() or makeConnection() call.
|
OptCounterInfo | getSavedOptCounterInfoForDelete(java.lang.Object aKey)
This method flushes the EJB cache if the specified EJB has been loaded.
|
OptCounterInfo | getSavedOptCounterInfoForOptimisticSelect(java.lang.Object aKey)
This method flushes the EJB cache if the specified EJB has been loaded.
|
OptCounterInfo | getSavedOptCounterInfoForUpdate(java.lang.Object aKey)
This method gets the OPTCOUNTER information for the specified key from the TransactionCache.
|
abstract javax.ejb.SessionContext | getSessionContext()
This method returns the session context that has been set by the setSessionContext() method.
|
static void | init(com.ibm.commerce.ejb.helpers.ConfigProperties parameters)
Deprecated.
Initialization of the JDBC session bean helper has been replaced with parameters specified in the deployment descriptor. Replaced by ConfiguratorBean.initDataSourceInfo().
|
static void | init(java.lang.String ds, java.lang.String dt, java.lang.String uid, java.lang.String pw)
Deprecated.
Initialization of the JDBC Session bean helper has been replaced with parameters specified in the deployment descriptor. Replaced by ConfiguratorBean.initDataSourceInfo().
|
protected void | makeConnection()
This method creates a JDBC connection if one does not already exist for the session bean or the existing connection is closed.
|
protected void | makeConnection(java.lang.String astrDSKey)
This method creates a JDBC connection from the data source given the data source key.
|
static boolean | useCloudscape()
This method returns whether the database the application is configured to use is Apache Derby.
|
static boolean | useDB2_390()
This method returns whether the application is configured to use the IBM UDB database for the 390 platform.
|
static boolean | useDB2_400()
Deprecated.
|
static boolean | useDB2()
This method returns whether the database the application is configured to use IBM UDB for the distributed platform.
|
static boolean | useOracle()
This method returns whether the database the application is configured to use is Oracle.
|
static boolean | useOracle9()
This method determines whether Oracle JDBC Version 9 is used as the database client.
|
public static final java.lang.String COPYRIGHT
public static final java.lang.String DB_DB2
public static final java.lang.String DB_ORACLE
public static final java.lang.String DB_DB2_390
public static final java.lang.String DB_DB2J
public static final java.lang.String DB_AS400
public static final boolean autoFlush
protected transient javax.ejb.SessionContext mySessionCtx
protected static final java.util.HashMap dataSourceConfigData
protected static final java.lang.String DATASOURCE
protected static final java.lang.String DBTYPE
protected static final java.lang.String ISDB2_390
protected static final java.lang.String CONTENT_DS
protected static final java.lang.String TRANSACTIONAL_DS
protected static final java.util.HashMap dsKeys
public BaseJDBCHelper()
protected void closeConnection() throws java.sql.SQLException
protected static java.util.Hashtable convertFirstRowToHashtable(java.sql.ResultSet aResultSet) throws java.sql.SQLException
public static java.util.Vector convertResultSetToTable(java.sql.ResultSet rs) throws java.sql.SQLException
protected static java.lang.String convertRowFromHashtable(java.util.Hashtable aHashtable) throws java.sql.SQLException
protected void debugInitConnection(java.lang.String dataSourceName, java.lang.String userId, java.lang.String pswd) throws javax.naming.NamingException, java.sql.SQLException
protected java.sql.ResultSet executeQuery(java.sql.PreparedStatement stmt, boolean bFlush) throws java.sql.SQLException
protected int executeUpdate(java.sql.PreparedStatement stmt, boolean bFlush) throws java.sql.SQLException
public void flush()
protected java.sql.CallableStatement getCallableStatement(java.lang.String sqlStatement) throws java.sql.SQLException
protected java.sql.Connection getConnection() throws javax.naming.NamingException, java.sql.SQLException
public static javax.sql.DataSource getDataSource() throws javax.naming.NamingException
public static javax.sql.DataSource getDataSource(java.lang.String astrDSKey) throws javax.naming.NamingException
protected java.sql.PreparedStatement getPreparedStatement(java.lang.String sqlStatement) throws java.sql.SQLException
The prepared statement that is created is cached and it is expected that at the end of the method the closeConnection() method will be called to clean up the created prepared statements and JDBC connection associated with this object.
protected java.sql.PreparedStatement getPreparedStatement(java.lang.String sqlStatement, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
The prepared statement that is created is cached an it is expected that at the end of the method the closeConnection() method will be called to clean up the created prepared statements and JDBC connection associated with this object.
public abstract javax.ejb.SessionContext getSessionContext()
public static void init(com.ibm.commerce.ejb.helpers.ConfigProperties parameters) throws javax.naming.NamingException
public static void init(java.lang.String ds, java.lang.String dt, java.lang.String uid, java.lang.String pw) throws javax.naming.NamingException
protected void makeConnection() throws javax.naming.NamingException, java.sql.SQLException
protected void makeConnection(java.lang.String astrDSKey) throws javax.naming.NamingException, java.sql.SQLException
public static boolean useDB2()
public static boolean useDB2_390()
public static boolean useOracle()
public static boolean useOracle9() throws javax.ejb.EJBException
public static boolean useCloudscape()
public static boolean useDB2_400()
public static java.lang.String getCharacterStreamFromResultSet(java.sql.ResultSet rs, int nColumn) throws java.sql.SQLException
public static java.lang.String buildCommaSeparatedWhereClause(int length)
public OptCounterInfo getSavedOptCounterInfoForUpdate(java.lang.Object aKey)
This method gets the OPTCOUNTER information for the specified key from the TransactionCache. It flushes the EJB cache if the saved OptCounterInfo object for the specified key indicates that the corresponding EJB bean has been loaded and the WHERE clause fragment should include the OPTCOUNTER value.
This method is called to obtain the OPTCOUNTER information to use it in a JDBC update operation.
The EJB cache needs to be flushed when an EJB bean has an outstanding update to the specified object. Otherwise, the update operation will increment the OPTCOUNTER value and the subsequent call to ejbStore will fail since it includes the value it loaded in its WHERE clause.
public OptCounterInfo getSavedOptCounterInfoForDelete(java.lang.Object aKey)
public OptCounterInfo getSavedOptCounterInfoForOptimisticSelect(java.lang.Object aKey)
protected final int executeOptimisticDelete(java.sql.PreparedStatement aPreparedOptimisticDeleteStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo) throws java.sql.SQLException
protected final int executeOptimisticUpdate(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo) throws java.sql.SQLException
protected final int executeOptimisticUpdateWithIncrementDecrement(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo, java.lang.String astrTableName, java.lang.String astrWhereClause, java.lang.Object[] aWhereClauseParameters, com.ibm.ivj.ejb.runtime.AbstractEntityAccessBean aAbstractEntityAccessBean) throws java.sql.SQLException, javax.ejb.EJBException, javax.naming.NamingException, javax.ejb.CreateException, javax.ejb.FinderException
This method calls the executeOptimisticUpdate(PreparedStatement,Object,OptCounterInfo) method. Then, if the OptCounterInfo EJBLoaded property is true, it creates and executes a statement to decrement the OPTCOUNTER column value.
If the decrement is successful, the Known property of the specified aOptCounterInfo object is set to false. Then, the specified AbstractEntityBean, if any, is dirtied by calling its commitCopyHelper method.
This method should not be called unless the caller can guarantee one of the following two things. The first is that the EJB is not loaded. The second is that, if it is loaded, its OptCounter EJBLoaded property has been set to true. If this is the case, the EJB's ejbStore method will be called when the transaction commits.
The EJBLoaded property will be set correctly if the following two things are true. Firstly, the EJB must be coded to call super.ejbLoad. Secondly, the EJB's ejbCreate methods must all call the super.initializeOptCounter method. The ejbStore method will be called if the EJB is dirty. A 1.1 EJB is considered dirty if one of its remote methods without the read access intent specified is called. A 2.0 EJB is considered dirty if one of its remote setter methods is called.
protected final java.sql.ResultSet executeOptimisticSelect(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, OptCounterInfo aOptCounterInfo) throws java.sql.SQLException
public static java.lang.String getInQueryClause(int nParameters)
public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex, int aColumnType) throws java.sql.SQLException
public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex, java.sql.ResultSetMetaData aResultSetMetaData) throws java.sql.SQLException
public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex) throws java.sql.SQLException
protected final int executeOptimisticInsert(java.sql.PreparedStatement aPreparedOptimisticUpdateStatement, java.lang.Object aOptCounterInfoKey, int aOptCounterParameterIndex) throws java.sql.SQLException