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.
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
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.
|
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.
|
static java.util.Vector |
convertResultSetToTable(java.sql.ResultSet rs)
This method converts the records found in the result set to a
Vector of
Vector s. |
void |
flush()
This method calls
flush(boolean) method with the value "true". |
void |
flush(boolean bEntityManagerFlush)
/**
This method writes the outstanding data changes to the database transaction log.
|
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. |
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 . |
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 . |
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() . |
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
IBM UDB
for the distributed platforms.public static final java.lang.String DB_ORACLE
public static final java.lang.String DB_DB2_390
IBM UDB
for 390.public static final java.lang.String DB_DB2J
public static final java.lang.String DB_AS400
public static final boolean autoFlush
public BaseJDBCHelper()
public static java.util.Vector convertResultSetToTable(java.sql.ResultSet rs) throws java.sql.SQLException
Vector
of
Vector
s. The resulting Vector
contains the number of
elements for the number of results found in the result set. Each element
of the Vector
is another Vector
where each element represents a column
of each record. The order of the column values match the order the columns
were specified when the SQL statement was executed.rs
- The result set to extract the information from.Vector
such that each element represents a record from the specified
result set.java.sql.SQLException
- This is thrown when there is a problem retrieving data
from a result set.public void flush(boolean bEntityManagerFlush)
BLOB
or CLOB
data that is
left outstanding because of Oracle limitations.bEntityManagerFlush
- flush entity data to the database if true. Otherwise, the database flush step will be skipped.public void flush()
flush(boolean)
method with the value "true".flush(boolean)
public static javax.sql.DataSource getDataSource() throws javax.naming.NamingException
javax.naming.NamingException
- This is thrown when the name of the data source cannot be resolved.public static javax.sql.DataSource getDataSource(java.lang.String astrDSKey) throws javax.naming.NamingException
strDSKey
- - The key to the data sourcejavax.naming.NamingException
- This is thrown when the name of the data source cannot be resolved.public static void init(com.ibm.commerce.ejb.helpers.ConfigProperties parameters)
ConfiguratorBean.initDataSourceInfo()
.parameters
- The configuration properties.public static void init(java.lang.String ds, java.lang.String dt, java.lang.String uid, java.lang.String pw)
ConfiguratorBean.initDataSourceInfo()
.ds
- The data source name.dt
- The database type.uid
- The user identity.pw
- The password of the user.public static boolean useDB2()
IBM UDB
for the distributed platform.IBM UDB
constant.public static boolean useDB2_390()
IBM UDB
database for the 390 platform.IBM UDB
constant
and the flag to indicate the database platform is 390.public static boolean useOracle()
public static boolean useOracle9() throws javax.ejb.EJBException
javax.ejb.EJBException
- This wraps the root cause exception.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
String
value of the specified column in the
result set. It does this by extracting the information from the character stream when
the target database is Oracle. Otherwise the getString()
method
will be used to retrieve the column data. This is used because of Oracle
limitations when dealing with columns containing large CLOB
and BLOB
data types.rs
- The result set to extract the data from.nColumn
- The column index of the data to extract.String
of character stream from result set.java.sql.SQLException
- This is thrown when there is a problem extracting the data.public static java.lang.String buildCommaSeparatedWhereClause(int length)
length
- The number of question marks to include.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.
aKey
- Uniquely identifies the table and row of the OPTCOUNTER
.
For objects with EJB beans, use its primary key object.
For example, for a UserBean
, use new MemberKey
(member_id
)
For JDBC helper classes when there is no corresponding EJB bean, use a unique row identifier.
For example, new ObjectTuple("STOREREL", storeId, relatedStoreId, relationshipTypeName)
OPTCOUNTER
information for the specified row,
or a new OptCounterInfo
constructed from the default constructor
if there was none in the transaction cache.public OptCounterInfo getSavedOptCounterInfoForDelete(java.lang.Object aKey)
OPTCOUNTER
information for a row of a table from the TransactionCache
.
This method is called to obtain the OPTCOUNTER
information to use it in a JDBC
delete
operation.
The EJB cache needs to be flushed when an EJB bean has an outstanding update
to the specified object. Otherwise, the JDBC delete
operation will
remove the row
and the subsequent call to ejbStore
will fail since the row no longer exists.aKey
- Uniquely identifies the table and row of the OPTCOUNTER
.
For an object with EJB beans, use its primary key object.
For example, for a UserBean
, use new MemberKey
(member_id
)
For JDBC helper classes when there is no corresponding EJB, use a unique row identifier.
For example, new ObjectTuple("STOREREL", storeId, relatedStoreId, relationshipTypeName)
OPTCOUNTER
information for the specified row,
or a new OptCounterInfo
constructed from the default constructor
if there was none in the transaction cache.public OptCounterInfo getSavedOptCounterInfoForOptimisticSelect(java.lang.Object aKey)
OPTCOUNTER
information for a row of a table from the TransactionCache
.
This method is called to obtain the OPTCOUNTER
information to use it in a JDBC
select for update
operation
that includes the OPTCOUNTER
value in its where
clause.
The EJB cache needs to be flushed when an EJB bean has an outstanding update
to the specified object. Otherwise, the JDBC operation may
obtain the wrong information.aKey
- Uniquely identifies the table and row of the OPTCOUNTER
.
For an object with EJB beans, use its primary key object.
For example, for a UserBean
, use new MemberKey
(member_id
)
For JDBC helper classes when there is no corresponding EJB, use a unique row identifier.
For example, new ObjectTuple("STOREREL", storeId, relatedStoreId, relationshipTypeName)
OPTCOUNTER
information for the specified row,
or a new OptCounterInfo
constructed from the default constructor
if there was none in the transaction cache.public static java.lang.String getInQueryClause(int nParameters)
IN
clause (for example, " IN(?,?)")
or equals clause ("=? ") when nParameters is one.nParameters
- The number of parameter markers to be placed in the clause.IN
or equals clause.
When nParameters is one the last character is a space. Otherwise
the first character is a space.public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex, int aColumnType) throws java.sql.SQLException
ResultSet
object as
a Java Object
.aResultSet
- The result set.aColumnIndex
- The first column is 1, the second is 2, ...aColumnType
- The column type of the column, returned from
aResultSet.getMetaData().getColumnType(aColumnIndex).
java.lang.Object
holding the column value .java.sql.SQLException
- This is thrown if a database access error occurs.public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex, java.sql.ResultSetMetaData aResultSetMetaData) throws java.sql.SQLException
ResultSet
object as
a Java Object
.aResultSet
- The result set.aColumnIndex
- The first column is 1, the second is 2, ...aResultSetMetaData
- The ResultSetMetaData
for the specified ResultSet
, returned from
aResultSet.getMetaData()
java.lang.Object
holding the column value.java.sql.SQLException
- This is thrown if a database access error occurs.public static java.lang.Object getObject(java.sql.ResultSet aResultSet, int aColumnIndex) throws java.sql.SQLException
ResultSet
object as
a Java Object
.aResultSet
- The result set.aColumnIndex
- The first column is 1, the second is 2, ...java.lang.Object
holding the column value.java.sql.SQLException
- This is thrown if a database access error occurs.