java.lang.Object | +--com.ibm.commerce.base.helpers.BaseJDBCHelper
JDBC helper class which provides interactation to the database. For example, initializing the datasource and executing the query.
Field Summary | |
---|---|
static boolean |
autoFlush The default value of the auto flush parameter. |
static java.lang.String |
COPYRIGHT IBM copyright notice field. |
protected
static java.lang.String |
DATASOURCE |
protected
static java.util.HashMap |
dataSourceConfigData |
static java.lang.String |
DB_DB2 The default value of the constant of DB2 database. |
static java.lang.String |
DB_DB2_390 The default value of the constant of a DB2 database running on a 390 system. |
static java.lang.String |
DB_DB2J The default value of the constant of DB Cloudscape database. |
static java.lang.String |
DB_ORACLE The default value of the constant of Oracle database. |
protected
static java.lang.String |
DBTYPE |
protected
javax.ejb.SessionContext |
mySessionCtx |
Constructor Summary | |
---|---|
BaseJDBCHelper() Constructor for BaseJDBCHelper. |
Method Summary | |
---|---|
static java.lang.String |
buildCommaSeparatedWhereClause(int length) Builds comma separated where clause by length |
protected
void |
closeConnection() Closes the database connection. |
protected
static java.util.Hashtable |
convertFirstRowToHashtable(java.sql.ResultSet aResultSet) Converts the first row of the input result set to a Hashtable. |
static java.util.Vector |
convertResultSetToTable(java.sql.ResultSet rs) Converts the input result set to a table. |
protected
static java.lang.String |
convertRowFromHashtable(java.util.Hashtable aHashtable) Converts the row in Hashtable to a SQL statment. |
protected
void |
debugInitConnection(java.lang.String dataSourceName,
java.lang.String userId, java.lang.String pswd) Debugs the initial data source connection. |
protected
java.sql.ResultSet |
executeQuery(java.sql.PreparedStatement stmt,
boolean flush) Executes the database query. |
protected
int |
executeUpdate(java.sql.PreparedStatement stmt,
boolean flush) Executes the database update statement. |
void |
flush() Flush the session context. |
protected
java.sql.CallableStatement |
getCallableStatement(java.lang.String sqlStatement) Gets the CallableStatement from SQL statement. |
static java.lang.String |
getCharacterStreamFromResultSet(java.sql.ResultSet rs,
int nColumn) Gets the characters stream from the result set |
protected
java.sql.Connection |
getConnection() Gets the data source connection. |
static javax.sql.DataSource |
getDataSource() Gets the default data source. |
protected
java.sql.PreparedStatement |
getPreparedStatement(java.lang.String sqlStatement) Gets the prepared statement. |
protected
java.sql.PreparedStatement |
getPreparedStatement(java.lang.String sqlStatement, int resultSetType,
int resultSetConcurrency) Gets the prepared statement. |
abstract
javax.ejb.SessionContext |
getSessionContext() Gets the session context. |
static void |
init(ConfigProperties parameters) Deprecated. Initialization of the JDBC Session bean helper has been replaced with parameters specified in the deployment descriptor. Replaced by com.ibm.commerce.base.objects.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 com.ibm.commerce.base.objects.ConfiguratorBean#initDataSourceInfo() . |
protected
void |
makeConnection() Creates connection to data source. |
static boolean |
useCloudscape() Checks if Cloudscape is used as database. |
static boolean |
useDB2_390() Checks if DB 390 is used as database |
static boolean |
useDB2() Checks if DB2 is used as database |
static boolean |
useOracle() Checks if Oracle is used as database |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll,
toString, wait, wait, wait |
Field Detail |
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 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
Constructor Detail |
public BaseJDBCHelper()
Method Detail |
protected void closeConnection() throws java.sql.SQLException
java.sql.SQLException
protected static java.util.Hashtable convertFirstRowToHashtable(java.sql.ResultSet aResultSet) throws java.sql.SQLException
aResultSet
- result set objectjava.sql.SQLException
public static java.util.Vector convertResultSetToTable(java.sql.ResultSet rs) throws java.sql.SQLException
rs
- result set objectjava.sql.SQLException
protected static java.lang.String convertRowFromHashtable(java.util.Hashtable aHashtable) throws java.sql.SQLException
aHashtable
- The result set objectjava.sql.SQLException
protected void debugInitConnection(java.lang.String dataSourceName, java.lang.String userId, java.lang.String pswd) throws javax.naming.NamingException, java.sql.SQLException
dataSourceName
- data source nameuserId
- user id to connect to data sourcepswd
- user passwordjavax.naming.NamingException
java.sql.SQLException
protected java.sql.ResultSet executeQuery(java.sql.PreparedStatement stmt, boolean flush) throws java.sql.SQLException
stmt
- prepare statment to be executedflush
- true if the flush is required; false otherwisejava.sql.SQLException
protected int executeUpdate(java.sql.PreparedStatement stmt, boolean flush) throws java.sql.SQLException
stmt
- prepare statment to be executedflush
- true if the flush is required; false otherwisejava.sql.SQLException
public void flush()
protected java.sql.CallableStatement getCallableStatement(java.lang.String sqlStatement) throws java.sql.SQLException
sqlStatement
- SQL statementjava.sql.SQLException
protected java.sql.Connection getConnection() throws javax.naming.NamingException, java.sql.SQLException
javax.naming.NamingException
java.sql.SQLException
public static javax.sql.DataSource getDataSource() throws javax.naming.NamingException
javax.naming.NamingException
protected java.sql.PreparedStatement getPreparedStatement(java.lang.String sqlStatement) throws java.sql.SQLException
sqlStatement
- SQL statementjava.sql.SQLException
protected java.sql.PreparedStatement getPreparedStatement(java.lang.String sqlStatement, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
sqlStatement
- SQL statementresultSetType
- result set typeresultSetConcurrency
- concurrency type of result setjava.sql.SQLException
public abstract javax.ejb.SessionContext getSessionContext()
public static void init(ConfigProperties parameters) throws javax.naming.NamingException
com.ibm.commerce.base.objects.ConfiguratorBean#initDataSourceInfo()
.
parameters
- configuration properties.javax.naming.NamingException
- a naming
exception.public static void init(java.lang.String ds, java.lang.String dt, java.lang.String uid, java.lang.String pw) throws javax.naming.NamingException
com.ibm.commerce.base.objects.ConfiguratorBean#initDataSourceInfo()
.
dt
- database typeuid
- user Idpw
- passwordjavax.naming.NamingException
- a naming
exception.protected void makeConnection() throws javax.naming.NamingException, java.sql.SQLException
javax.naming.NamingException
java.sql.SQLException
public static boolean useDB2()
public static boolean useDB2_390()
public static boolean useOracle()
public static boolean useCloudscape()
public static java.lang.String getCharacterStreamFromResultSet(java.sql.ResultSet rs, int nColumn) throws java.sql.SQLException
rs
- Result setnColumn
- column indexjava.sql.SQLException
public static java.lang.String buildCommaSeparatedWhereClause(int length)
length
- The length used to separate the where clause