net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWSchema.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWSchema.java

Source

// Description: Java 7 DB/2 LUW 10.5 Jdbc DbIO implementation for CFCrm.

/*
 *   CF Customer Relations Management model
 *
 *   Copyright (c) 2014 Mark Sobkow
 *   
 *      Licensed under the Apache License, Version 2.0 (the "License");
 *      you may not use this file except in compliance with the License.
 *      You may obtain a copy of the License at
 *   
 *          http://www.apache.org/licenses/LICENSE-2.0
 *   
 *      Unless required by applicable law or agreed to in writing, software
 *      distributed under the License is distributed on an "AS IS" BASIS,
 *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *      See the License for the specific language governing permissions and
 *      limitations under the License.
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW;

import java.lang.reflect.*;
import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import javax.naming.*;
import javax.sql.*;
import net.sourceforge.msscodefactory.cflib.v2_1.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrm.*;

public class CFCrmDb2LUWSchema extends CFCrmSchema {
    protected Connection cnx;
    protected boolean inTransaction;
    protected PreparedStatement stmtSelectNextServiceTypeIdGen = null;
    protected PreparedStatement stmtSelectNextMimeTypeIdGen = null;
    protected PreparedStatement stmtSelectNextClusterIdGen = null;
    protected PreparedStatement stmtSelectNextTenantIdGen = null;
    protected PreparedStatement stmtSelectIsSystemUser = null;
    protected PreparedStatement stmtSelectIsClusterUser = null;
    protected PreparedStatement stmtSelectIsTenantUser = null;

    public CFCrmDb2LUWSchema() {
        super();
        cnx = null;
        inTransaction = false;
        tableAddress = new CFCrmDb2LUWAddressTable(this);
        tableAddressTag = new CFCrmDb2LUWAddressTagTable(this);
        tableAttachment = new CFCrmDb2LUWAttachmentTable(this);
        tableAttachmentTag = new CFCrmDb2LUWAttachmentTagTable(this);
        tableAuditAction = new CFCrmDb2LUWAuditActionTable(this);
        tableCluster = new CFCrmDb2LUWClusterTable(this);
        tableContact = new CFCrmDb2LUWContactTable(this);
        tableContactList = new CFCrmDb2LUWContactListTable(this);
        tableContactTag = new CFCrmDb2LUWContactTagTable(this);
        tableContactURL = new CFCrmDb2LUWContactURLTable(this);
        tableDomain = new CFCrmDb2LUWDomainTable(this);
        tableDomainBase = new CFCrmDb2LUWDomainBaseTable(this);
        tableHostNode = new CFCrmDb2LUWHostNodeTable(this);
        tableISOCountry = new CFCrmDb2LUWISOCountryTable(this);
        tableISOCountryCurrency = new CFCrmDb2LUWISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFCrmDb2LUWISOCountryLanguageTable(this);
        tableISOCurrency = new CFCrmDb2LUWISOCurrencyTable(this);
        tableISOLanguage = new CFCrmDb2LUWISOLanguageTable(this);
        tableISOTimezone = new CFCrmDb2LUWISOTimezoneTable(this);
        tableMajorVersion = new CFCrmDb2LUWMajorVersionTable(this);
        tableMemo = new CFCrmDb2LUWMemoTable(this);
        tableMemoTag = new CFCrmDb2LUWMemoTagTable(this);
        tableMimeType = new CFCrmDb2LUWMimeTypeTable(this);
        tableMinorVersion = new CFCrmDb2LUWMinorVersionTable(this);
        tablePhone = new CFCrmDb2LUWPhoneTable(this);
        tablePhoneTag = new CFCrmDb2LUWPhoneTagTable(this);
        tableProjectBase = new CFCrmDb2LUWProjectBaseTable(this);
        tableRealProject = new CFCrmDb2LUWRealProjectTable(this);
        tableSecApp = new CFCrmDb2LUWSecAppTable(this);
        tableSecDevice = new CFCrmDb2LUWSecDeviceTable(this);
        tableSecForm = new CFCrmDb2LUWSecFormTable(this);
        tableSecGroup = new CFCrmDb2LUWSecGroupTable(this);
        tableSecGroupForm = new CFCrmDb2LUWSecGroupFormTable(this);
        tableSecGroupInclude = new CFCrmDb2LUWSecGroupIncludeTable(this);
        tableSecGroupMember = new CFCrmDb2LUWSecGroupMemberTable(this);
        tableSecSession = new CFCrmDb2LUWSecSessionTable(this);
        tableSecUser = new CFCrmDb2LUWSecUserTable(this);
        tableService = new CFCrmDb2LUWServiceTable(this);
        tableServiceType = new CFCrmDb2LUWServiceTypeTable(this);
        tableSubProject = new CFCrmDb2LUWSubProjectTable(this);
        tableTSecGroup = new CFCrmDb2LUWTSecGroupTable(this);
        tableTSecGroupInclude = new CFCrmDb2LUWTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFCrmDb2LUWTSecGroupMemberTable(this);
        tableTag = new CFCrmDb2LUWTagTable(this);
        tableTenant = new CFCrmDb2LUWTenantTable(this);
        tableTld = new CFCrmDb2LUWTldTable(this);
        tableTopDomain = new CFCrmDb2LUWTopDomainTable(this);
        tableTopProject = new CFCrmDb2LUWTopProjectTable(this);
        tableURLProtocol = new CFCrmDb2LUWURLProtocolTable(this);
        tableVersion = new CFCrmDb2LUWVersionTable(this);
    }

    public CFCrmDb2LUWSchema(CFCrmConfigurationFile conf) {
        super(conf);
        cnx = null;
        inTransaction = false;
        tableAddress = new CFCrmDb2LUWAddressTable(this);
        tableAddressTag = new CFCrmDb2LUWAddressTagTable(this);
        tableAttachment = new CFCrmDb2LUWAttachmentTable(this);
        tableAttachmentTag = new CFCrmDb2LUWAttachmentTagTable(this);
        tableAuditAction = new CFCrmDb2LUWAuditActionTable(this);
        tableCluster = new CFCrmDb2LUWClusterTable(this);
        tableContact = new CFCrmDb2LUWContactTable(this);
        tableContactList = new CFCrmDb2LUWContactListTable(this);
        tableContactTag = new CFCrmDb2LUWContactTagTable(this);
        tableContactURL = new CFCrmDb2LUWContactURLTable(this);
        tableDomain = new CFCrmDb2LUWDomainTable(this);
        tableDomainBase = new CFCrmDb2LUWDomainBaseTable(this);
        tableHostNode = new CFCrmDb2LUWHostNodeTable(this);
        tableISOCountry = new CFCrmDb2LUWISOCountryTable(this);
        tableISOCountryCurrency = new CFCrmDb2LUWISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFCrmDb2LUWISOCountryLanguageTable(this);
        tableISOCurrency = new CFCrmDb2LUWISOCurrencyTable(this);
        tableISOLanguage = new CFCrmDb2LUWISOLanguageTable(this);
        tableISOTimezone = new CFCrmDb2LUWISOTimezoneTable(this);
        tableMajorVersion = new CFCrmDb2LUWMajorVersionTable(this);
        tableMemo = new CFCrmDb2LUWMemoTable(this);
        tableMemoTag = new CFCrmDb2LUWMemoTagTable(this);
        tableMimeType = new CFCrmDb2LUWMimeTypeTable(this);
        tableMinorVersion = new CFCrmDb2LUWMinorVersionTable(this);
        tablePhone = new CFCrmDb2LUWPhoneTable(this);
        tablePhoneTag = new CFCrmDb2LUWPhoneTagTable(this);
        tableProjectBase = new CFCrmDb2LUWProjectBaseTable(this);
        tableRealProject = new CFCrmDb2LUWRealProjectTable(this);
        tableSecApp = new CFCrmDb2LUWSecAppTable(this);
        tableSecDevice = new CFCrmDb2LUWSecDeviceTable(this);
        tableSecForm = new CFCrmDb2LUWSecFormTable(this);
        tableSecGroup = new CFCrmDb2LUWSecGroupTable(this);
        tableSecGroupForm = new CFCrmDb2LUWSecGroupFormTable(this);
        tableSecGroupInclude = new CFCrmDb2LUWSecGroupIncludeTable(this);
        tableSecGroupMember = new CFCrmDb2LUWSecGroupMemberTable(this);
        tableSecSession = new CFCrmDb2LUWSecSessionTable(this);
        tableSecUser = new CFCrmDb2LUWSecUserTable(this);
        tableService = new CFCrmDb2LUWServiceTable(this);
        tableServiceType = new CFCrmDb2LUWServiceTypeTable(this);
        tableSubProject = new CFCrmDb2LUWSubProjectTable(this);
        tableTSecGroup = new CFCrmDb2LUWTSecGroupTable(this);
        tableTSecGroupInclude = new CFCrmDb2LUWTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFCrmDb2LUWTSecGroupMemberTable(this);
        tableTag = new CFCrmDb2LUWTagTable(this);
        tableTenant = new CFCrmDb2LUWTenantTable(this);
        tableTld = new CFCrmDb2LUWTldTable(this);
        tableTopDomain = new CFCrmDb2LUWTopDomainTable(this);
        tableTopProject = new CFCrmDb2LUWTopProjectTable(this);
        tableURLProtocol = new CFCrmDb2LUWURLProtocolTable(this);
        tableVersion = new CFCrmDb2LUWVersionTable(this);
        setDbSchemaName(conf.getDbDatabase());
    }

    public CFCrmDb2LUWSchema(String argJndiName) {
        super(argJndiName);
        cnx = null;
        inTransaction = false;
        tableAddress = new CFCrmDb2LUWAddressTable(this);
        tableAddressTag = new CFCrmDb2LUWAddressTagTable(this);
        tableAttachment = new CFCrmDb2LUWAttachmentTable(this);
        tableAttachmentTag = new CFCrmDb2LUWAttachmentTagTable(this);
        tableAuditAction = new CFCrmDb2LUWAuditActionTable(this);
        tableCluster = new CFCrmDb2LUWClusterTable(this);
        tableContact = new CFCrmDb2LUWContactTable(this);
        tableContactList = new CFCrmDb2LUWContactListTable(this);
        tableContactTag = new CFCrmDb2LUWContactTagTable(this);
        tableContactURL = new CFCrmDb2LUWContactURLTable(this);
        tableDomain = new CFCrmDb2LUWDomainTable(this);
        tableDomainBase = new CFCrmDb2LUWDomainBaseTable(this);
        tableHostNode = new CFCrmDb2LUWHostNodeTable(this);
        tableISOCountry = new CFCrmDb2LUWISOCountryTable(this);
        tableISOCountryCurrency = new CFCrmDb2LUWISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFCrmDb2LUWISOCountryLanguageTable(this);
        tableISOCurrency = new CFCrmDb2LUWISOCurrencyTable(this);
        tableISOLanguage = new CFCrmDb2LUWISOLanguageTable(this);
        tableISOTimezone = new CFCrmDb2LUWISOTimezoneTable(this);
        tableMajorVersion = new CFCrmDb2LUWMajorVersionTable(this);
        tableMemo = new CFCrmDb2LUWMemoTable(this);
        tableMemoTag = new CFCrmDb2LUWMemoTagTable(this);
        tableMimeType = new CFCrmDb2LUWMimeTypeTable(this);
        tableMinorVersion = new CFCrmDb2LUWMinorVersionTable(this);
        tablePhone = new CFCrmDb2LUWPhoneTable(this);
        tablePhoneTag = new CFCrmDb2LUWPhoneTagTable(this);
        tableProjectBase = new CFCrmDb2LUWProjectBaseTable(this);
        tableRealProject = new CFCrmDb2LUWRealProjectTable(this);
        tableSecApp = new CFCrmDb2LUWSecAppTable(this);
        tableSecDevice = new CFCrmDb2LUWSecDeviceTable(this);
        tableSecForm = new CFCrmDb2LUWSecFormTable(this);
        tableSecGroup = new CFCrmDb2LUWSecGroupTable(this);
        tableSecGroupForm = new CFCrmDb2LUWSecGroupFormTable(this);
        tableSecGroupInclude = new CFCrmDb2LUWSecGroupIncludeTable(this);
        tableSecGroupMember = new CFCrmDb2LUWSecGroupMemberTable(this);
        tableSecSession = new CFCrmDb2LUWSecSessionTable(this);
        tableSecUser = new CFCrmDb2LUWSecUserTable(this);
        tableService = new CFCrmDb2LUWServiceTable(this);
        tableServiceType = new CFCrmDb2LUWServiceTypeTable(this);
        tableSubProject = new CFCrmDb2LUWSubProjectTable(this);
        tableTSecGroup = new CFCrmDb2LUWTSecGroupTable(this);
        tableTSecGroupInclude = new CFCrmDb2LUWTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFCrmDb2LUWTSecGroupMemberTable(this);
        tableTag = new CFCrmDb2LUWTagTable(this);
        tableTenant = new CFCrmDb2LUWTenantTable(this);
        tableTld = new CFCrmDb2LUWTldTable(this);
        tableTopDomain = new CFCrmDb2LUWTopDomainTable(this);
        tableTopProject = new CFCrmDb2LUWTopProjectTable(this);
        tableURLProtocol = new CFCrmDb2LUWURLProtocolTable(this);
        tableVersion = new CFCrmDb2LUWVersionTable(this);
    }

    public CFCrmDb2LUWSchema(Connection argCnx) {
        super();
        cnx = argCnx;
        inTransaction = false;
        tableAddress = new CFCrmDb2LUWAddressTable(this);
        tableAddressTag = new CFCrmDb2LUWAddressTagTable(this);
        tableAttachment = new CFCrmDb2LUWAttachmentTable(this);
        tableAttachmentTag = new CFCrmDb2LUWAttachmentTagTable(this);
        tableAuditAction = new CFCrmDb2LUWAuditActionTable(this);
        tableCluster = new CFCrmDb2LUWClusterTable(this);
        tableContact = new CFCrmDb2LUWContactTable(this);
        tableContactList = new CFCrmDb2LUWContactListTable(this);
        tableContactTag = new CFCrmDb2LUWContactTagTable(this);
        tableContactURL = new CFCrmDb2LUWContactURLTable(this);
        tableDomain = new CFCrmDb2LUWDomainTable(this);
        tableDomainBase = new CFCrmDb2LUWDomainBaseTable(this);
        tableHostNode = new CFCrmDb2LUWHostNodeTable(this);
        tableISOCountry = new CFCrmDb2LUWISOCountryTable(this);
        tableISOCountryCurrency = new CFCrmDb2LUWISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFCrmDb2LUWISOCountryLanguageTable(this);
        tableISOCurrency = new CFCrmDb2LUWISOCurrencyTable(this);
        tableISOLanguage = new CFCrmDb2LUWISOLanguageTable(this);
        tableISOTimezone = new CFCrmDb2LUWISOTimezoneTable(this);
        tableMajorVersion = new CFCrmDb2LUWMajorVersionTable(this);
        tableMemo = new CFCrmDb2LUWMemoTable(this);
        tableMemoTag = new CFCrmDb2LUWMemoTagTable(this);
        tableMimeType = new CFCrmDb2LUWMimeTypeTable(this);
        tableMinorVersion = new CFCrmDb2LUWMinorVersionTable(this);
        tablePhone = new CFCrmDb2LUWPhoneTable(this);
        tablePhoneTag = new CFCrmDb2LUWPhoneTagTable(this);
        tableProjectBase = new CFCrmDb2LUWProjectBaseTable(this);
        tableRealProject = new CFCrmDb2LUWRealProjectTable(this);
        tableSecApp = new CFCrmDb2LUWSecAppTable(this);
        tableSecDevice = new CFCrmDb2LUWSecDeviceTable(this);
        tableSecForm = new CFCrmDb2LUWSecFormTable(this);
        tableSecGroup = new CFCrmDb2LUWSecGroupTable(this);
        tableSecGroupForm = new CFCrmDb2LUWSecGroupFormTable(this);
        tableSecGroupInclude = new CFCrmDb2LUWSecGroupIncludeTable(this);
        tableSecGroupMember = new CFCrmDb2LUWSecGroupMemberTable(this);
        tableSecSession = new CFCrmDb2LUWSecSessionTable(this);
        tableSecUser = new CFCrmDb2LUWSecUserTable(this);
        tableService = new CFCrmDb2LUWServiceTable(this);
        tableServiceType = new CFCrmDb2LUWServiceTypeTable(this);
        tableSubProject = new CFCrmDb2LUWSubProjectTable(this);
        tableTSecGroup = new CFCrmDb2LUWTSecGroupTable(this);
        tableTSecGroupInclude = new CFCrmDb2LUWTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFCrmDb2LUWTSecGroupMemberTable(this);
        tableTag = new CFCrmDb2LUWTagTable(this);
        tableTenant = new CFCrmDb2LUWTenantTable(this);
        tableTld = new CFCrmDb2LUWTldTable(this);
        tableTopDomain = new CFCrmDb2LUWTopDomainTable(this);
        tableTopProject = new CFCrmDb2LUWTopProjectTable(this);
        tableURLProtocol = new CFCrmDb2LUWURLProtocolTable(this);
        tableVersion = new CFCrmDb2LUWVersionTable(this);
        try {
            cnx.setAutoCommit(false);
            cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
            cnx.rollback();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "CFCrmDb2LUWSchema-constructor", e);
        }
    }

    public Connection getCnx() {
        return (cnx);
    }

    public boolean isConnected() {
        final String S_ProcName = "isConnected";
        boolean retval;
        if (cnx == null) {
            retval = false;
        } else {
            try {
                if (cnx.isClosed()) {
                    retval = false;
                    cnx = null;
                    releasePreparedStatements();
                } else {
                    retval = true;
                }
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
        }
        return (retval);
    }

    public boolean connect() {
        final String S_ProcName = "connect";
        if (cnx != null) {
            return (false);
        }

        if (configuration != null) {
            try {
                Class.forName("com.ibm.db2.jcc.DB2Driver");
            } catch (ClassNotFoundException e) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "connect",
                        "Could not load IBM DB/2 LUW 10.5 driver", e);
            }
            String dbServer = configuration.getDbServer();
            int dbPort = configuration.getDbPort();
            String dbDatabase = configuration.getDbDatabase();
            String dbUserName = configuration.getDbUserName();
            String dbPassword = configuration.getDbPassword();
            String url = "jdbc:db2://" + dbServer + ":" + Integer.toString(dbPort) + "/" + dbDatabase;
            Properties props = new Properties();
            props.setProperty("user", dbUserName);
            props.setProperty("password", dbPassword);
            try {
                cnx = DriverManager.getConnection(url, props);
                cnx.setAutoCommit(false);
                cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                cnx.rollback();
                setDbSchemaName(dbDatabase);
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            return (true);
        }
        if (jndiName != null) {
            try {
                Context ctx = new InitialContext();
                DataSource ds = (DataSource) ctx.lookup(jndiName);
                if (ds == null) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Could not get resolve DataSource \"" + jndiName + "\"");
                }
                cnx = ds.getConnection();
                if (cnx == null) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Could not get Connection from PooledConnection for ConnectionPoolDataSource \""
                                    + jndiName + "\"");
                }
                cnx.setAutoCommit(false);
                cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                cnx.rollback();
            } catch (NamingException e) {
                cnx = null;
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NamingException " + e.getMessage(), e);
            } catch (SQLException e) {
                cnx = null;
                inTransaction = false;
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            return (true);
        }
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Neither configurationFile nor jndiName found, do not know how to connect to database");
    }

    public boolean connect(String username, String password) {
        final String S_ProcName = "connect-userpw";
        if (cnx != null) {
            return (false);
        }
        if ((username == null) || (username.length() <= 0)) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                    "username");
        }
        if (password == null) {
            throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                    "password");
        }

        if (configuration != null) {
            try {
                Class.forName("com.ibm.db2.jcc.DB2Driver");
            } catch (ClassNotFoundException e) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "connect",
                        "Could not load IBM DB/2 LUW 10.5 driver", e);
            }
            String dbServer = configuration.getDbServer();
            int dbPort = configuration.getDbPort();
            String dbDatabase = configuration.getDbDatabase();
            String dbUserName = username;
            String dbPassword = password;
            String url = "jdbc:db2://" + dbServer + ":" + Integer.toString(dbPort) + "/" + dbDatabase;
            Properties props = new Properties();
            props.setProperty("user", dbUserName);
            props.setProperty("password", dbPassword);
            try {
                cnx = DriverManager.getConnection(url, props);
                cnx.setAutoCommit(false);
                cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
                cnx.rollback();
                setDbSchemaName(dbDatabase);
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            return (true);
        }
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "configurationFile not found, do not know how to connect to database");
    }

    public boolean connect(String clustername, String tenantname, String secUserName, String dbUserName,
            String dbPassword) {
        boolean retval = connect(dbUserName, dbPassword);
        return (retval);
    }

    public void disconnect(boolean doCommit) {
        final String S_ProcName = "disconnect";
        if (cnx != null) {
            try {
                if (!cnx.isClosed()) {
                    if (doCommit) {
                        cnx.commit();
                    } else {
                        cnx.rollback();
                    }
                    releasePreparedStatements();
                    cnx.close();
                }
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            } finally {
                cnx = null;
            }
        }
        releasePreparedStatements();
    }

    public boolean isTransactionOpen() {
        return (inTransaction);
    }

    public boolean beginTransaction() {
        if (inTransaction) {
            return (false);
        }
        //      try {
        //         String sql =
        //               "begin transaction";
        //         Statement stmt = cnx.createStatement( ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY );
        //         stmt.execute( sql );
        inTransaction = true;
        //      }
        //      catch( SQLException e ) {
        //         throw CFLib.getDefaultExceptionFactory().newDbException( getClass(),
        //            "beginTransaction",
        //            e );
        //      }
        return (inTransaction);
    }

    public void commit() {
        try {
            cnx.commit();
            inTransaction = false;
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "commit", e);
        }
    }

    public void rollback() {
        try {
            cnx.rollback();
            inTransaction = false;
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "rollback", e);
        }
    }

    public boolean isSystemUser(CFCrmAuthorization Authorization) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "SELECT sp_is_system_user( ? ) as IsSystemUser FROM sysibm.sysdummy1";
            if (stmtSelectIsSystemUser == null) {
                stmtSelectIsSystemUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsSystemUser.setString(1, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsSystemUser.executeQuery();
            int resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getInt(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isSystemUser",
                        "Query of sp_is_system_user() did not return a result row");
            }
            resultSet.close();
            if (resultFlag == 0) {
                return (false);
            } else {
                return (true);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public boolean isClusterUser(CFCrmAuthorization Authorization, long clusterId, String groupName) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isClusterUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "SELECT sp_is_cluster_user( ?, ?, ? ) as IsClusterUser FROM sysibm.sysdummy1";
            if (stmtSelectIsClusterUser == null) {
                stmtSelectIsClusterUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsClusterUser.setLong(1, clusterId);
            stmtSelectIsClusterUser.setString(2, groupName);
            stmtSelectIsClusterUser.setString(3, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsClusterUser.executeQuery();
            int resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getInt(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isClusterUser",
                        "Query of sp_is_cluster_user() did not return a result row");
            }
            resultSet.close();
            if (resultFlag == 0) {
                return (false);
            } else {
                return (true);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isClusterUser", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public boolean isTenantUser(CFCrmAuthorization Authorization, long tenantId, String groupName) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isTenantUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "SELECT sp_is_tenant_user( ?, ?, ? ) as IsTenantUser FROM sysibm.sysdummy1";
            if (stmtSelectIsTenantUser == null) {
                stmtSelectIsTenantUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsTenantUser.setLong(1, tenantId);
            stmtSelectIsTenantUser.setString(2, groupName);
            stmtSelectIsTenantUser.setString(3, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsTenantUser.executeQuery();
            int resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getInt(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isTenantUser",
                        "Query of sp_is_tenant_user() did not return a result row");
            }
            resultSet.close();
            if (resultFlag == 0) {
                return (false);
            } else {
                return (true);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isTenantUser", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public int nextServiceTypeIdGen() {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextServiceTypeIdGen",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "call sf_next_servicetypeidgen()";
            if (stmtSelectNextServiceTypeIdGen == null) {
                stmtSelectNextServiceTypeIdGen = cnx.prepareStatement(sql);
            }
            resultSet = stmtSelectNextServiceTypeIdGen.executeQuery();
            int nextId;
            if (resultSet.next()) {
                nextId = resultSet.getInt(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "nextServiceTypeIdGen",
                        "Query of sf_next_servicetypeidgen() did not return a result row");
            }
            resultSet.close();
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextServiceTypeIdGen", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public int nextMimeTypeIdGen() {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextMimeTypeIdGen",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "call sf_next_mimetypeidgen()";
            if (stmtSelectNextMimeTypeIdGen == null) {
                stmtSelectNextMimeTypeIdGen = cnx.prepareStatement(sql);
            }
            resultSet = stmtSelectNextMimeTypeIdGen.executeQuery();
            int nextId;
            if (resultSet.next()) {
                nextId = resultSet.getInt(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "nextMimeTypeIdGen",
                        "Query of sf_next_mimetypeidgen() did not return a result row");
            }
            resultSet.close();
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextMimeTypeIdGen", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public long nextClusterIdGen() {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextClusterIdGen",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "call sf_next_clusteridgen()";
            if (stmtSelectNextClusterIdGen == null) {
                stmtSelectNextClusterIdGen = cnx.prepareStatement(sql);
            }
            resultSet = stmtSelectNextClusterIdGen.executeQuery();
            long nextId;
            if (resultSet.next()) {
                nextId = resultSet.getLong(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "nextClusterIdGen",
                        "Query of sf_next_clusteridgen() did not return a result row");
            }
            resultSet.close();
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextClusterIdGen", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public long nextTenantIdGen() {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "nextTenantIdGen",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            final String sql = "call sf_next_tenantidgen()";
            if (stmtSelectNextTenantIdGen == null) {
                stmtSelectNextTenantIdGen = cnx.prepareStatement(sql);
            }
            resultSet = stmtSelectNextTenantIdGen.executeQuery();
            long nextId;
            if (resultSet.next()) {
                nextId = resultSet.getLong(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "nextTenantIdGen",
                        "Query of sf_next_tenantidgen() did not return a result row");
            }
            resultSet.close();
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "nextTenantIdGen", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public UUID nextSecSessionIdGen() {
        UUID retval = UUID.randomUUID();
        return (retval);
    }

    public UUID nextSecUserIdGen() {
        UUID retval = UUID.randomUUID();
        return (retval);
    }

    /**
     *   Release the prepared statements.
     *   <p>
     *   When the schema changes connections, the prepared statements
     *   have to be released because they contain connection-specific
     *   information for most databases.
     */
    public void releasePreparedStatements() {
        final String S_ProcName = "releasePreparedStatements";

        if (stmtSelectNextServiceTypeIdGen != null) {
            try {
                stmtSelectNextServiceTypeIdGen.close();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            stmtSelectNextServiceTypeIdGen = null;
        }
        if (stmtSelectNextMimeTypeIdGen != null) {
            try {
                stmtSelectNextMimeTypeIdGen.close();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            stmtSelectNextMimeTypeIdGen = null;
        }
        if (stmtSelectNextClusterIdGen != null) {
            try {
                stmtSelectNextClusterIdGen.close();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            stmtSelectNextClusterIdGen = null;
        }
        if (stmtSelectNextTenantIdGen != null) {
            try {
                stmtSelectNextTenantIdGen.close();
            } catch (SQLException e) {
                throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
            }
            stmtSelectNextTenantIdGen = null;
        }

        if ((tableAddress != null) && (tableAddress instanceof CFCrmDb2LUWAddressTable)) {
            CFCrmDb2LUWAddressTable table = (CFCrmDb2LUWAddressTable) tableAddress;
            table.releasePreparedStatements();
        }
        if ((tableAddressTag != null) && (tableAddressTag instanceof CFCrmDb2LUWAddressTagTable)) {
            CFCrmDb2LUWAddressTagTable table = (CFCrmDb2LUWAddressTagTable) tableAddressTag;
            table.releasePreparedStatements();
        }
        if ((tableAttachment != null) && (tableAttachment instanceof CFCrmDb2LUWAttachmentTable)) {
            CFCrmDb2LUWAttachmentTable table = (CFCrmDb2LUWAttachmentTable) tableAttachment;
            table.releasePreparedStatements();
        }
        if ((tableAttachmentTag != null) && (tableAttachmentTag instanceof CFCrmDb2LUWAttachmentTagTable)) {
            CFCrmDb2LUWAttachmentTagTable table = (CFCrmDb2LUWAttachmentTagTable) tableAttachmentTag;
            table.releasePreparedStatements();
        }
        if ((tableAuditAction != null) && (tableAuditAction instanceof CFCrmDb2LUWAuditActionTable)) {
            CFCrmDb2LUWAuditActionTable table = (CFCrmDb2LUWAuditActionTable) tableAuditAction;
            table.releasePreparedStatements();
        }
        if ((tableCluster != null) && (tableCluster instanceof CFCrmDb2LUWClusterTable)) {
            CFCrmDb2LUWClusterTable table = (CFCrmDb2LUWClusterTable) tableCluster;
            table.releasePreparedStatements();
        }
        if ((tableContact != null) && (tableContact instanceof CFCrmDb2LUWContactTable)) {
            CFCrmDb2LUWContactTable table = (CFCrmDb2LUWContactTable) tableContact;
            table.releasePreparedStatements();
        }
        if ((tableContactList != null) && (tableContactList instanceof CFCrmDb2LUWContactListTable)) {
            CFCrmDb2LUWContactListTable table = (CFCrmDb2LUWContactListTable) tableContactList;
            table.releasePreparedStatements();
        }
        if ((tableContactTag != null) && (tableContactTag instanceof CFCrmDb2LUWContactTagTable)) {
            CFCrmDb2LUWContactTagTable table = (CFCrmDb2LUWContactTagTable) tableContactTag;
            table.releasePreparedStatements();
        }
        if ((tableContactURL != null) && (tableContactURL instanceof CFCrmDb2LUWContactURLTable)) {
            CFCrmDb2LUWContactURLTable table = (CFCrmDb2LUWContactURLTable) tableContactURL;
            table.releasePreparedStatements();
        }
        if ((tableDomain != null) && (tableDomain instanceof CFCrmDb2LUWDomainTable)) {
            CFCrmDb2LUWDomainTable table = (CFCrmDb2LUWDomainTable) tableDomain;
            table.releasePreparedStatements();
        }
        if ((tableDomainBase != null) && (tableDomainBase instanceof CFCrmDb2LUWDomainBaseTable)) {
            CFCrmDb2LUWDomainBaseTable table = (CFCrmDb2LUWDomainBaseTable) tableDomainBase;
            table.releasePreparedStatements();
        }
        if ((tableHostNode != null) && (tableHostNode instanceof CFCrmDb2LUWHostNodeTable)) {
            CFCrmDb2LUWHostNodeTable table = (CFCrmDb2LUWHostNodeTable) tableHostNode;
            table.releasePreparedStatements();
        }
        if ((tableISOCountry != null) && (tableISOCountry instanceof CFCrmDb2LUWISOCountryTable)) {
            CFCrmDb2LUWISOCountryTable table = (CFCrmDb2LUWISOCountryTable) tableISOCountry;
            table.releasePreparedStatements();
        }
        if ((tableISOCountryCurrency != null)
                && (tableISOCountryCurrency instanceof CFCrmDb2LUWISOCountryCurrencyTable)) {
            CFCrmDb2LUWISOCountryCurrencyTable table = (CFCrmDb2LUWISOCountryCurrencyTable) tableISOCountryCurrency;
            table.releasePreparedStatements();
        }
        if ((tableISOCountryLanguage != null)
                && (tableISOCountryLanguage instanceof CFCrmDb2LUWISOCountryLanguageTable)) {
            CFCrmDb2LUWISOCountryLanguageTable table = (CFCrmDb2LUWISOCountryLanguageTable) tableISOCountryLanguage;
            table.releasePreparedStatements();
        }
        if ((tableISOCurrency != null) && (tableISOCurrency instanceof CFCrmDb2LUWISOCurrencyTable)) {
            CFCrmDb2LUWISOCurrencyTable table = (CFCrmDb2LUWISOCurrencyTable) tableISOCurrency;
            table.releasePreparedStatements();
        }
        if ((tableISOLanguage != null) && (tableISOLanguage instanceof CFCrmDb2LUWISOLanguageTable)) {
            CFCrmDb2LUWISOLanguageTable table = (CFCrmDb2LUWISOLanguageTable) tableISOLanguage;
            table.releasePreparedStatements();
        }
        if ((tableISOTimezone != null) && (tableISOTimezone instanceof CFCrmDb2LUWISOTimezoneTable)) {
            CFCrmDb2LUWISOTimezoneTable table = (CFCrmDb2LUWISOTimezoneTable) tableISOTimezone;
            table.releasePreparedStatements();
        }
        if ((tableMajorVersion != null) && (tableMajorVersion instanceof CFCrmDb2LUWMajorVersionTable)) {
            CFCrmDb2LUWMajorVersionTable table = (CFCrmDb2LUWMajorVersionTable) tableMajorVersion;
            table.releasePreparedStatements();
        }
        if ((tableMemo != null) && (tableMemo instanceof CFCrmDb2LUWMemoTable)) {
            CFCrmDb2LUWMemoTable table = (CFCrmDb2LUWMemoTable) tableMemo;
            table.releasePreparedStatements();
        }
        if ((tableMemoTag != null) && (tableMemoTag instanceof CFCrmDb2LUWMemoTagTable)) {
            CFCrmDb2LUWMemoTagTable table = (CFCrmDb2LUWMemoTagTable) tableMemoTag;
            table.releasePreparedStatements();
        }
        if ((tableMimeType != null) && (tableMimeType instanceof CFCrmDb2LUWMimeTypeTable)) {
            CFCrmDb2LUWMimeTypeTable table = (CFCrmDb2LUWMimeTypeTable) tableMimeType;
            table.releasePreparedStatements();
        }
        if ((tableMinorVersion != null) && (tableMinorVersion instanceof CFCrmDb2LUWMinorVersionTable)) {
            CFCrmDb2LUWMinorVersionTable table = (CFCrmDb2LUWMinorVersionTable) tableMinorVersion;
            table.releasePreparedStatements();
        }
        if ((tablePhone != null) && (tablePhone instanceof CFCrmDb2LUWPhoneTable)) {
            CFCrmDb2LUWPhoneTable table = (CFCrmDb2LUWPhoneTable) tablePhone;
            table.releasePreparedStatements();
        }
        if ((tablePhoneTag != null) && (tablePhoneTag instanceof CFCrmDb2LUWPhoneTagTable)) {
            CFCrmDb2LUWPhoneTagTable table = (CFCrmDb2LUWPhoneTagTable) tablePhoneTag;
            table.releasePreparedStatements();
        }
        if ((tableProjectBase != null) && (tableProjectBase instanceof CFCrmDb2LUWProjectBaseTable)) {
            CFCrmDb2LUWProjectBaseTable table = (CFCrmDb2LUWProjectBaseTable) tableProjectBase;
            table.releasePreparedStatements();
        }
        if ((tableRealProject != null) && (tableRealProject instanceof CFCrmDb2LUWRealProjectTable)) {
            CFCrmDb2LUWRealProjectTable table = (CFCrmDb2LUWRealProjectTable) tableRealProject;
            table.releasePreparedStatements();
        }
        if ((tableSecApp != null) && (tableSecApp instanceof CFCrmDb2LUWSecAppTable)) {
            CFCrmDb2LUWSecAppTable table = (CFCrmDb2LUWSecAppTable) tableSecApp;
            table.releasePreparedStatements();
        }
        if ((tableSecDevice != null) && (tableSecDevice instanceof CFCrmDb2LUWSecDeviceTable)) {
            CFCrmDb2LUWSecDeviceTable table = (CFCrmDb2LUWSecDeviceTable) tableSecDevice;
            table.releasePreparedStatements();
        }
        if ((tableSecForm != null) && (tableSecForm instanceof CFCrmDb2LUWSecFormTable)) {
            CFCrmDb2LUWSecFormTable table = (CFCrmDb2LUWSecFormTable) tableSecForm;
            table.releasePreparedStatements();
        }
        if ((tableSecGroup != null) && (tableSecGroup instanceof CFCrmDb2LUWSecGroupTable)) {
            CFCrmDb2LUWSecGroupTable table = (CFCrmDb2LUWSecGroupTable) tableSecGroup;
            table.releasePreparedStatements();
        }
        if ((tableSecGroupForm != null) && (tableSecGroupForm instanceof CFCrmDb2LUWSecGroupFormTable)) {
            CFCrmDb2LUWSecGroupFormTable table = (CFCrmDb2LUWSecGroupFormTable) tableSecGroupForm;
            table.releasePreparedStatements();
        }
        if ((tableSecGroupInclude != null) && (tableSecGroupInclude instanceof CFCrmDb2LUWSecGroupIncludeTable)) {
            CFCrmDb2LUWSecGroupIncludeTable table = (CFCrmDb2LUWSecGroupIncludeTable) tableSecGroupInclude;
            table.releasePreparedStatements();
        }
        if ((tableSecGroupMember != null) && (tableSecGroupMember instanceof CFCrmDb2LUWSecGroupMemberTable)) {
            CFCrmDb2LUWSecGroupMemberTable table = (CFCrmDb2LUWSecGroupMemberTable) tableSecGroupMember;
            table.releasePreparedStatements();
        }
        if ((tableSecSession != null) && (tableSecSession instanceof CFCrmDb2LUWSecSessionTable)) {
            CFCrmDb2LUWSecSessionTable table = (CFCrmDb2LUWSecSessionTable) tableSecSession;
            table.releasePreparedStatements();
        }
        if ((tableSecUser != null) && (tableSecUser instanceof CFCrmDb2LUWSecUserTable)) {
            CFCrmDb2LUWSecUserTable table = (CFCrmDb2LUWSecUserTable) tableSecUser;
            table.releasePreparedStatements();
        }
        if ((tableService != null) && (tableService instanceof CFCrmDb2LUWServiceTable)) {
            CFCrmDb2LUWServiceTable table = (CFCrmDb2LUWServiceTable) tableService;
            table.releasePreparedStatements();
        }
        if ((tableServiceType != null) && (tableServiceType instanceof CFCrmDb2LUWServiceTypeTable)) {
            CFCrmDb2LUWServiceTypeTable table = (CFCrmDb2LUWServiceTypeTable) tableServiceType;
            table.releasePreparedStatements();
        }
        if ((tableSubProject != null) && (tableSubProject instanceof CFCrmDb2LUWSubProjectTable)) {
            CFCrmDb2LUWSubProjectTable table = (CFCrmDb2LUWSubProjectTable) tableSubProject;
            table.releasePreparedStatements();
        }
        if ((tableTSecGroup != null) && (tableTSecGroup instanceof CFCrmDb2LUWTSecGroupTable)) {
            CFCrmDb2LUWTSecGroupTable table = (CFCrmDb2LUWTSecGroupTable) tableTSecGroup;
            table.releasePreparedStatements();
        }
        if ((tableTSecGroupInclude != null)
                && (tableTSecGroupInclude instanceof CFCrmDb2LUWTSecGroupIncludeTable)) {
            CFCrmDb2LUWTSecGroupIncludeTable table = (CFCrmDb2LUWTSecGroupIncludeTable) tableTSecGroupInclude;
            table.releasePreparedStatements();
        }
        if ((tableTSecGroupMember != null) && (tableTSecGroupMember instanceof CFCrmDb2LUWTSecGroupMemberTable)) {
            CFCrmDb2LUWTSecGroupMemberTable table = (CFCrmDb2LUWTSecGroupMemberTable) tableTSecGroupMember;
            table.releasePreparedStatements();
        }
        if ((tableTag != null) && (tableTag instanceof CFCrmDb2LUWTagTable)) {
            CFCrmDb2LUWTagTable table = (CFCrmDb2LUWTagTable) tableTag;
            table.releasePreparedStatements();
        }
        if ((tableTenant != null) && (tableTenant instanceof CFCrmDb2LUWTenantTable)) {
            CFCrmDb2LUWTenantTable table = (CFCrmDb2LUWTenantTable) tableTenant;
            table.releasePreparedStatements();
        }
        if ((tableTld != null) && (tableTld instanceof CFCrmDb2LUWTldTable)) {
            CFCrmDb2LUWTldTable table = (CFCrmDb2LUWTldTable) tableTld;
            table.releasePreparedStatements();
        }
        if ((tableTopDomain != null) && (tableTopDomain instanceof CFCrmDb2LUWTopDomainTable)) {
            CFCrmDb2LUWTopDomainTable table = (CFCrmDb2LUWTopDomainTable) tableTopDomain;
            table.releasePreparedStatements();
        }
        if ((tableTopProject != null) && (tableTopProject instanceof CFCrmDb2LUWTopProjectTable)) {
            CFCrmDb2LUWTopProjectTable table = (CFCrmDb2LUWTopProjectTable) tableTopProject;
            table.releasePreparedStatements();
        }
        if ((tableURLProtocol != null) && (tableURLProtocol instanceof CFCrmDb2LUWURLProtocolTable)) {
            CFCrmDb2LUWURLProtocolTable table = (CFCrmDb2LUWURLProtocolTable) tableURLProtocol;
            table.releasePreparedStatements();
        }
        if ((tableVersion != null) && (tableVersion instanceof CFCrmDb2LUWVersionTable)) {
            CFCrmDb2LUWVersionTable table = (CFCrmDb2LUWVersionTable) tableVersion;
            table.releasePreparedStatements();
        }
    }

    public static String getQuotedString(String val) {
        if (val == null) {
            return ("null");
        } else {
            char c;
            StringBuilder quoted = new StringBuilder();
            quoted.append("'");
            int len = val.length();
            for (int i = 0; i < len; i++) {
                if (val.charAt(i) == '\'') {
                    quoted.append("''");
                } else if (val.charAt(i) == '\\') {
                    quoted.append("'||E'\\\\'||'");
                } else {
                    c = val.charAt(i);
                    if ((c == '0') || (c == '1') || (c == '2') || (c == '3') || (c == '4') || (c == '5')
                            || (c == '6') || (c == '7') || (c == '8') || (c == '9') || (c == 'a') || (c == 'b')
                            || (c == 'c') || (c == 'd') || (c == 'e') || (c == 'f') || (c == 'g') || (c == 'h')
                            || (c == 'i') || (c == 'j') || (c == 'k') || (c == 'l') || (c == 'm') || (c == 'n')
                            || (c == 'o') || (c == 'p') || (c == 'q') || (c == 'r') || (c == 's') || (c == 't')
                            || (c == 'u') || (c == 'v') || (c == 'w') || (c == 'x') || (c == 'y') || (c == 'z')
                            || (c == 'A') || (c == 'B') || (c == 'C') || (c == 'D') || (c == 'E') || (c == 'F')
                            || (c == 'G') || (c == 'H') || (c == 'I') || (c == 'J') || (c == 'K') || (c == 'L')
                            || (c == 'M') || (c == 'N') || (c == 'O') || (c == 'P') || (c == 'Q') || (c == 'R')
                            || (c == 'S') || (c == 'T') || (c == 'U') || (c == 'V') || (c == 'W') || (c == 'X')
                            || (c == 'Y') || (c == 'Z') || (c == ' ') || (c == '\t') || (c == '\r') || (c == '\n')
                            || (c == '`') || (c == '~') || (c == '!') || (c == '@') || (c == '#') || (c == '$')
                            || (c == '%') || (c == '^') || (c == '&') || (c == '*') || (c == '(') || (c == ')')
                            || (c == '-') || (c == '_') || (c == '=') || (c == '+') || (c == '[') || (c == ']')
                            || (c == '{') || (c == '}') || (c == '|') || (c == ';') || (c == ':') || (c == '"')
                            || (c == '<') || (c == '>') || (c == ',') || (c == '.') || (c == '/') || (c == '?')) {
                        quoted.append(c);
                    } else {
                        //                  Syslog.warn("\t\t\tReplacing invalid character '" + c + "' with space");
                        quoted.append(' ');
                    }
                }
            }
            quoted.append("'");
            return (quoted.toString());
        }
    }

    public static String getNullableString(ResultSet reader, int colidx) {
        try {
            String val = reader.getString(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (val);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableString",
                    e);
        }
    }

    public static String getBlobString(byte[] val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + Base64.encodeBase64(val).toString() + "'");
        }
    }

    public static String getBoolString(Boolean val) {
        if (val == null) {
            return ("null");
        } else {
            if (val) {
                return ("'Y'");
            } else {
                return ("'N'");
            }
        }
    }

    public static String getBoolString(boolean val) {
        if (val) {
            return ("'Y'");
        } else {
            return ("'N'");
        }
    }

    public static String getInt16String(Short val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt16String(short val) {
        return (Short.toString(val));
    }

    public static String getInt32String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt32String(int val) {
        return (Integer.toString(val));
    }

    public static String getInt64String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getInt64String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt16String(Integer val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt16String(int val) {
        return (Integer.toString(val));
    }

    public static String getUInt32String(Long val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getUInt32String(long val) {
        return (Long.toString(val));
    }

    public static String getUInt64String(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(Float val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getFloatString(float val) {
        return (Float.toString(val));
    }

    public static String getDoubleString(Double val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static String getDoubleString(double val) {
        return (Double.toString(val));
    }

    public static String getNumberString(BigDecimal val) {
        if (val == null) {
            return ("null");
        } else {
            return (val.toString());
        }
    }

    public static Integer getNullableInt32(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableInt32", e);
        }
    }

    public static Short getNullableInt16(ResultSet reader, int colidx) {
        try {
            short val = reader.getShort(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Short(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableInt64", e);
        }
    }

    public static Integer getNullableUInt16(ResultSet reader, int colidx) {
        try {
            int val = reader.getInt(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Integer(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableUInt16",
                    e);
        }
    }

    public static Long getNullableUInt32(ResultSet reader, int colidx) {
        try {
            long val = reader.getLong(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Long(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableUInt32",
                    e);
        }
    }

    public static BigDecimal getNullableUInt64(ResultSet reader, int colidx) {
        try {
            String strval = reader.getString(colidx);
            if (reader.wasNull() || (strval == null) || (strval.length() <= 0)) {
                return (null);
            } else {
                BigDecimal retval = new BigDecimal(strval);
                return (retval);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableUInt64",
                    e);
        }
    }

    public static Byte getNullableByte(ResultSet reader, int colidx) {
        try {
            byte val = reader.getByte(colidx);
            if (reader.wasNull()) {
                return (null);
            } else {
                return (new Byte(val));
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(CFCrmDb2LUWSchema.class, "getNullableByte", e);
        }
    }

    public static String getQuotedDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getQuotedTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer("'");
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            buff.append("'");
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZDateString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimeString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getTZTimestampString(Calendar val) {
        if (val == null) {
            return ("null");
        } else {
            Calendar db = CFLibDbUtil.getDbServerCalendar(val);
            StringBuffer buff = new StringBuffer();
            Formatter fmt = new Formatter(buff);
            fmt.format("%1$04d", db.get(Calendar.YEAR));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.MONTH) + 1);
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.DAY_OF_MONTH));
            buff.append("-");
            fmt.format("%1$02d", db.get(Calendar.HOUR_OF_DAY));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.MINUTE));
            buff.append(".");
            fmt.format("%1$02d", db.get(Calendar.SECOND));
            fmt.close();
            return (buff.toString());
        }
    }

    public static String getUuidString(UUID val) {
        if (val == null) {
            return ("null");
        } else {
            return ("'" + val.toString() + "'");
        }
    }

    public static Calendar convertDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 10) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class, "convertDateString",
                    "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, 0);
            retval.set(Calendar.MINUTE, 0);
            retval.set(Calendar.SECOND, 0);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class, "convertDateString",
                    "Value must be in YYYY-MM-DD format, \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 8) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class, "convertTimeString",
                    "Value must be in HH24.MI.SS format, \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '2'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9')) && (val.charAt(2) == '.')
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '5'))
                && ((val.charAt(4) >= '0') && (val.charAt(4) <= '9')) && (val.charAt(5) == '.')
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '5'))
                && ((val.charAt(7) >= '0') && (val.charAt(7) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int hour = Integer.parseInt(val.substring(0, 2));
            int minute = Integer.parseInt(val.substring(3, 5));
            int second = Integer.parseInt(val.substring(6, 8));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, 2000);
            retval.set(Calendar.MONTH, 0);
            retval.set(Calendar.DAY_OF_MONTH, 1);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class, "convertTimeString",
                    "Value must be in HH24.MI.SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == '-')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == '.')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == '.')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar local = new GregorianCalendar();
            local.setTimeInMillis(retval.getTimeInMillis());
            return (local);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTimestampString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZDateString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == '-')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == '.')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == '.')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZDateString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimeString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD HH24.MI.SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == '-')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == '.')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == '.')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZTimeString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        }
    }

    public static Calendar convertTZTimestampString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else if (val.length() != 19) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        } else if (((val.charAt(0) >= '0') && (val.charAt(0) <= '9'))
                && ((val.charAt(1) >= '0') && (val.charAt(1) <= '9'))
                && ((val.charAt(2) >= '0') && (val.charAt(2) <= '9'))
                && ((val.charAt(3) >= '0') && (val.charAt(3) <= '9')) && (val.charAt(4) == '-')
                && ((val.charAt(5) >= '0') && (val.charAt(5) <= '1'))
                && ((val.charAt(6) >= '0') && (val.charAt(6) <= '9')) && (val.charAt(7) == '-')
                && ((val.charAt(8) >= '0') && (val.charAt(8) <= '3'))
                && ((val.charAt(9) >= '0') && (val.charAt(9) <= '9')) && (val.charAt(10) == '-')
                && ((val.charAt(11) >= '0') && (val.charAt(11) <= '2'))
                && ((val.charAt(12) >= '0') && (val.charAt(12) <= '9')) && (val.charAt(13) == '.')
                && ((val.charAt(14) >= '0') && (val.charAt(14) <= '5'))
                && ((val.charAt(15) >= '0') && (val.charAt(15) <= '9')) && (val.charAt(16) == '.')
                && ((val.charAt(17) >= '0') && (val.charAt(17) <= '5'))
                && ((val.charAt(18) >= '0') && (val.charAt(18) <= '9'))) {
            /*
             *   NOTE:
             *      .Net uses substring( startcol, lengthOfSubstring )
             *      Java uses substring( startcol, endcol ) and does not
             *         include charAt( endcol );
             */
            int year = Integer.parseInt(val.substring(0, 4));
            int month = Integer.parseInt(val.substring(5, 7));
            int day = Integer.parseInt(val.substring(8, 10));
            int hour = Integer.parseInt(val.substring(11, 13));
            int minute = Integer.parseInt(val.substring(14, 16));
            int second = Integer.parseInt(val.substring(17, 19));
            Calendar retval = new GregorianCalendar(CFLibDbUtil.getDbServerTimeZone());
            retval.set(Calendar.YEAR, year);
            retval.set(Calendar.MONTH, month - 1);
            retval.set(Calendar.DAY_OF_MONTH, day);
            retval.set(Calendar.HOUR_OF_DAY, hour);
            retval.set(Calendar.MINUTE, minute);
            retval.set(Calendar.SECOND, second);
            Calendar utc = CFLibDbUtil.getUTCCalendar(retval);
            return (utc);
        } else {
            throw CFLib.getDefaultExceptionFactory().newUsageException(CFCrmDb2LUWSchema.class,
                    "convertTZTimestampString",
                    "Value must be in YYYY-MM-DD-HH24.MI.SS format \"" + val + "\" is invalid");
        }
    }

    public static UUID convertUuidString(String val) {
        if ((val == null) || (val.length() == 0)) {
            return (null);
        } else {
            return (UUID.fromString(val));
        }
    }
}