Class DB2AS400DataStoreHelper

  • All Implemented Interfaces:
    DataStoreHelper

    public class DB2AS400DataStoreHelper
    extends DB2DataStoreHelper
    DB2AS400DataStoreHelper is a DataStoreHelper implementation customized for DB2 on IBM i. When mapping a SQLException, the SQLException mappings from the DB2DataStoreHelper are searched first, and subsequently, if no match is found, the SQLException mappings from the GenericDataStoreHelper are searched. If you have additional requirements on DB2 on IBM i you should consider subclassing this implementation.
    Note: This class and its methods can not be called or referenced directly by user applications.
    • Constructor Detail

      • DB2AS400DataStoreHelper

        public DB2AS400DataStoreHelper​(java.util.Properties props)
        This DB2AS400DataStoreHelper constructor creates a new DB2AS400DataStoreHelper based on the DataStoreHelper properties provided. All implementations inheriting from a data store helper must supply this same list of properties to their super class by invoking the constructor of their super class with the list of properties.
        Parameters:
        props - DataStoreHelper properties.
    • Method Detail

      • 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. Liberty 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 Liberty that at least one standard connection property was modified. A value of false is returned only if no standard connection properties were modified.

        DB2AS400DataStoreHelper clears all SQLWarnings on the connection.

        Specified by:
        doConnectionCleanup in interface DataStoreHelper
        Overrides:
        doConnectionCleanup in class GenericDataStoreHelper
        Parameters:
        conn - the connection to attempt to clean up.
        Returns:
        false because no standard connection properties are modified.
        Throws:
        java.sql.SQLException - If an error occurs while cleaning up the connection.
      • 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
        • fetchDirection
        • maxFieldSize
        • maxRows
        • queryTimeout

        DB2AS400DataStoreHelper resets all five of the properties listed above.

        The following operations do not need to be included in the statement cleanup since they are automatically performed by Liberty 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 DB2DataStoreHelper
        Parameters:
        stmt - the PreparedStatement.
        Throws:
        java.sql.SQLException - if an error occurs cleaning up the statement.