com.ibm.commerce.base.helpers

Class BaseJDBCHelper

  • java.lang.Object
    • com.ibm.commerce.base.helpers.BaseJDBCHelper
    • Field Summary

      Fields 
      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 Summary

      Constructors 
      Constructor and Description
      BaseJDBCHelper()
      This is the default constructor for this class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      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 Vectors.
      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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • DB_DB2

        public static final 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.
        See Also:
        Constant Field Values
      • DB_ORACLE

        public static final java.lang.String DB_ORACLE
        This is a constant that is used by the configurator bean to indicate the target database is Oracle.
        See Also:
        Constant Field Values
      • DB_DB2_390

        public static final 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.
        See Also:
        Constant Field Values
      • DB_DB2J

        public static final java.lang.String DB_DB2J
        This is a constant that is used by the configurator bean to indicate the target database is Apache Derby.
        See Also:
        Constant Field Values
      • DB_AS400

        public static final java.lang.String DB_AS400
        For IBM internal use only.
        See Also:
        Constant Field Values
      • autoFlush

        public static final 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.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BaseJDBCHelper

        public BaseJDBCHelper()
        This is the default constructor for this class. It calls the constructor from the superclass.
    • Method Detail

      • convertResultSetToTable

        public static java.util.Vector convertResultSetToTable(java.sql.ResultSet rs)
                                                        throws java.sql.SQLException
        This method converts the records found in the result set to a Vector of Vectors. 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.
        Parameters:
        rs - The result set to extract the information from.
        Returns:
        A Vector such that each element represents a record from the specified result set.
        Throws:
        java.sql.SQLException - This is thrown when there is a problem retrieving data from a result set.
      • flush

        public void flush(boolean bEntityManagerFlush)
        /** This method writes the outstanding data changes to the database transaction log. This outstanding data will be one of two things. It could be changes to the data contained in entity beans. It could also be any BLOB or CLOB data that is left outstanding because of Oracle limitations.
        Parameters:
        bEntityManagerFlush - flush entity data to the database if true. Otherwise, the database flush step will be skipped.
      • getDataSource

        public static javax.sql.DataSource getDataSource()
                                                  throws javax.naming.NamingException
        This method returns the data source that is associated with the application. The data source returned is the one specified on the deployment of the configurator bean. This session bean contains the database configuration associated with the product.
        Returns:
        The default data source associated with the product.
        Throws:
        javax.naming.NamingException - This is thrown when the name of the data source cannot be resolved.
      • getDataSource

        public static javax.sql.DataSource getDataSource(java.lang.String astrDSKey)
                                                  throws javax.naming.NamingException
        This method returns the data source that is associated with the application for a given data source key. The key is mapped to the data source local reference name in the dataaccess.xml configuration file. This reference name is used to lookup the data source configured in the deployment descriptor of the configurator session bean. This session bean contains the database configuration associated with the product.
        Parameters:
        strDSKey - - The key to the data source
        Returns:
        The default data source associated with the product.
        Throws:
        javax.naming.NamingException - This is thrown when the name of the data source cannot be resolved.
      • init

        public 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().
        This method does not perform any operations. Its original purpose was to initialize the database connection. However, since there are constant changes to the data source as the J2EE specification develops, this method no longer initializes the database connection.
        Parameters:
        parameters - The configuration properties.
      • init

        public 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().
        This method does not perform any operations. Its original purpose was to initialize the database connection. However, since there are constant changes to the data source as the J2EE specification develops, this method no longer initializes the database connection.
        Parameters:
        ds - The data source name.
        dt - The database type.
        uid - The user identity.
        pw - The password of the user.
      • useDB2

        public static boolean useDB2()
        This method returns whether the database the application is configured to use IBM UDB for the distributed platform.
        Returns:
        Whether the database type specified in the configurator bean is set to the IBM UDB constant.
      • useDB2_390

        public static boolean useDB2_390()
        This method returns whether the application is configured to use the IBM UDB database for the 390 platform.
        Returns:
        Whether the following two things are true: the database type specified in the configurator bean is set to the IBM UDB constant and the flag to indicate the database platform is 390.
      • useOracle

        public static boolean useOracle()
        This method returns whether the database the application is configured to use is Oracle.
        Returns:
        Whether the database type specified in the configurator bean is set to the Oracle constant.
      • useOracle9

        public static boolean useOracle9()
                                  throws javax.ejb.EJBException
        This method determines whether Oracle JDBC Version 9 is used as the database client.
        Returns:
        Whether Oracle JDBC Version 9 is used as the database client.
        Throws:
        javax.ejb.EJBException - This wraps the root cause exception.
      • useCloudscape

        public static boolean useCloudscape()
        This method returns whether the database the application is configured to use is Apache Derby.
        Returns:
        Whether the database type specified in the configurator bean is set to the Apache Derby constant.
      • useDB2_400

        public static boolean useDB2_400()
        Deprecated. 
        For IBM internal use only.
      • getCharacterStreamFromResultSet

        public static java.lang.String getCharacterStreamFromResultSet(java.sql.ResultSet rs,
                                                                       int nColumn)
                                                                throws java.sql.SQLException
        This method returns the 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.
        Parameters:
        rs - The result set to extract the data from.
        nColumn - The column index of the data to extract.
        Returns:
        A String of character stream from result set.
        Throws:
        java.sql.SQLException - This is thrown when there is a problem extracting the data.
      • buildCommaSeparatedWhereClause

        public static java.lang.String buildCommaSeparatedWhereClause(int length)
        This method builds common separated list of question marks based on the length specified. For example if 3 is given as an input parameter the result would be (?, ?, ?). This can later be used when dynamically building SQL statements to be used as a prepared statement.
        Parameters:
        length - The number of question marks to include.
        Returns:
        A common separated list of question marks.
      • getSavedOptCounterInfoForUpdate

        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.

        Parameters:
        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)
        Returns:
        The OPTCOUNTER information for the specified row, or a new OptCounterInfo constructed from the default constructor if there was none in the transaction cache.
      • getSavedOptCounterInfoForDelete

        public OptCounterInfo getSavedOptCounterInfoForDelete(java.lang.Object aKey)
        This method flushes the EJB cache if the specified EJB has been loaded. It then gets the 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.
        Parameters:
        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)
        Returns:
        The OPTCOUNTER information for the specified row, or a new OptCounterInfo constructed from the default constructor if there was none in the transaction cache.
      • getSavedOptCounterInfoForOptimisticSelect

        public OptCounterInfo getSavedOptCounterInfoForOptimisticSelect(java.lang.Object aKey)
        This method flushes the EJB cache if the specified EJB has been loaded. It then gets the 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.
        Parameters:
        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)
        Returns:
        The OPTCOUNTER information for the specified row, or a new OptCounterInfo constructed from the default constructor if there was none in the transaction cache.
      • getInQueryClause

        public 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.
        Parameters:
        nParameters - The number of parameter markers to be placed in the clause.
        Returns:
        The parameterized SQL IN or equals clause. When nParameters is one the last character is a space. Otherwise the first character is a space.
      • getObject

        public static java.lang.Object getObject(java.sql.ResultSet aResultSet,
                                                 int aColumnIndex,
                                                 int aColumnType)
                                          throws java.sql.SQLException
        This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
        Parameters:
        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).
        Returns:
        A java.lang.Object holding the column value .
        Throws:
        java.sql.SQLException - This is thrown if a database access error occurs.
      • getObject

        public static java.lang.Object getObject(java.sql.ResultSet aResultSet,
                                                 int aColumnIndex,
                                                 java.sql.ResultSetMetaData aResultSetMetaData)
                                          throws java.sql.SQLException
        This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
        Parameters:
        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()
        Returns:
        A java.lang.Object holding the column value.
        Throws:
        java.sql.SQLException - This is thrown if a database access error occurs.
      • getObject

        public static java.lang.Object getObject(java.sql.ResultSet aResultSet,
                                                 int aColumnIndex)
                                          throws java.sql.SQLException
        This method gets the value of the designated column in the current row of the specified ResultSet object as a Java Object.
        Parameters:
        aResultSet - The result set.
        aColumnIndex - The first column is 1, the second is 2, ...
        Returns:
        A java.lang.Object holding the column value.
        Throws:
        java.sql.SQLException - This is thrown if a database access error occurs.