net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlSchema.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql.CFFswMySqlSchema.java

Source

// Description: Java 7 MySQL Jdbc DbIO implementation for CFFsw.

/*
 *   CF FreeSwitch Configuration Model
 *
 *   Copyright (c) 2014 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *     
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.1-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.1-cfinternet.xml), and
 *      CFCrm 2.1 (net-sourceforge-msscodefactory-2.1-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 2.0
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 2.0 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cffreeswitch.v2_1.CFFswMySql;

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.cffreeswitch.v2_1.CFFsw.*;

public class CFFswMySqlSchema extends CFFswSchema {
    protected Connection cnx;
    protected boolean inTransaction;
    protected PreparedStatement stmtSelectIsSystemUser = null;
    protected PreparedStatement stmtSelectIsClusterUser = null;
    protected PreparedStatement stmtSelectIsTenantUser = null;
    protected PreparedStatement stmtSelectNextServiceTypeIdGen = null;
    protected PreparedStatement stmtInsertNextServiceTypeIdGen = null;
    protected PreparedStatement stmtUpdateNextServiceTypeIdGen = null;
    protected PreparedStatement stmtSelectNextMimeTypeIdGen = null;
    protected PreparedStatement stmtInsertNextMimeTypeIdGen = null;
    protected PreparedStatement stmtUpdateNextMimeTypeIdGen = null;
    protected PreparedStatement stmtSelectNextClusterIdGen = null;
    protected PreparedStatement stmtInsertNextClusterIdGen = null;
    protected PreparedStatement stmtUpdateNextClusterIdGen = null;
    protected PreparedStatement stmtSelectNextTenantIdGen = null;
    protected PreparedStatement stmtInsertNextTenantIdGen = null;
    protected PreparedStatement stmtUpdateNextTenantIdGen = null;

    public CFFswMySqlSchema() {
        super();
        cnx = null;
        inTransaction = false;
        tableAuditAction = new CFFswMySqlAuditActionTable(this);
        tableCluster = new CFFswMySqlClusterTable(this);
        tableDomain = new CFFswMySqlDomainTable(this);
        tableDomainBase = new CFFswMySqlDomainBaseTable(this);
        tableFSSFConference = new CFFswMySqlFSSFConferenceTable(this);
        tableFSSFConferenceProfile = new CFFswMySqlFSSFConferenceProfileTable(this);
        tableFSSFDialer = new CFFswMySqlFSSFDialerTable(this);
        tableFSSFDialplan = new CFFswMySqlFSSFDialplanTable(this);
        tableFSSFDirectory = new CFFswMySqlFSSFDirectoryTable(this);
        tableFSSFExtension = new CFFswMySqlFSSFExtensionTable(this);
        tableFSSFGateway = new CFFswMySqlFSSFGatewayTable(this);
        tableFSSFProfile = new CFFswMySqlFSSFProfileTable(this);
        tableFSSFProfileAlias = new CFFswMySqlFSSFProfileAliasTable(this);
        tableFSSFProfileDomain = new CFFswMySqlFSSFProfileDomainTable(this);
        tableFSSFVMail = new CFFswMySqlFSSFVMailTable(this);
        tableFSSofia = new CFFswMySqlFSSofiaTable(this);
        tableHostNode = new CFFswMySqlHostNodeTable(this);
        tableISOCountry = new CFFswMySqlISOCountryTable(this);
        tableISOCountryCurrency = new CFFswMySqlISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFFswMySqlISOCountryLanguageTable(this);
        tableISOCurrency = new CFFswMySqlISOCurrencyTable(this);
        tableISOLanguage = new CFFswMySqlISOLanguageTable(this);
        tableISOTimezone = new CFFswMySqlISOTimezoneTable(this);
        tableMajorVersion = new CFFswMySqlMajorVersionTable(this);
        tableMimeType = new CFFswMySqlMimeTypeTable(this);
        tableMinorVersion = new CFFswMySqlMinorVersionTable(this);
        tablePbxIvrMenu = new CFFswMySqlPbxIvrMenuTable(this);
        tablePbxIvrMenuEntry = new CFFswMySqlPbxIvrMenuEntryTable(this);
        tableProjectBase = new CFFswMySqlProjectBaseTable(this);
        tableRealProject = new CFFswMySqlRealProjectTable(this);
        tableSecApp = new CFFswMySqlSecAppTable(this);
        tableSecDevice = new CFFswMySqlSecDeviceTable(this);
        tableSecForm = new CFFswMySqlSecFormTable(this);
        tableSecGroup = new CFFswMySqlSecGroupTable(this);
        tableSecGroupForm = new CFFswMySqlSecGroupFormTable(this);
        tableSecGroupInclude = new CFFswMySqlSecGroupIncludeTable(this);
        tableSecGroupMember = new CFFswMySqlSecGroupMemberTable(this);
        tableSecSession = new CFFswMySqlSecSessionTable(this);
        tableSecUser = new CFFswMySqlSecUserTable(this);
        tableService = new CFFswMySqlServiceTable(this);
        tableServiceType = new CFFswMySqlServiceTypeTable(this);
        tableSubProject = new CFFswMySqlSubProjectTable(this);
        tableTSecGroup = new CFFswMySqlTSecGroupTable(this);
        tableTSecGroupInclude = new CFFswMySqlTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFFswMySqlTSecGroupMemberTable(this);
        tableTenant = new CFFswMySqlTenantTable(this);
        tableTld = new CFFswMySqlTldTable(this);
        tableTopDomain = new CFFswMySqlTopDomainTable(this);
        tableTopProject = new CFFswMySqlTopProjectTable(this);
        tableURLProtocol = new CFFswMySqlURLProtocolTable(this);
        tableVersion = new CFFswMySqlVersionTable(this);
    }

    public CFFswMySqlSchema(CFFswConfigurationFile conf) {
        super(conf);
        cnx = null;
        inTransaction = false;
        tableAuditAction = new CFFswMySqlAuditActionTable(this);
        tableCluster = new CFFswMySqlClusterTable(this);
        tableDomain = new CFFswMySqlDomainTable(this);
        tableDomainBase = new CFFswMySqlDomainBaseTable(this);
        tableFSSFConference = new CFFswMySqlFSSFConferenceTable(this);
        tableFSSFConferenceProfile = new CFFswMySqlFSSFConferenceProfileTable(this);
        tableFSSFDialer = new CFFswMySqlFSSFDialerTable(this);
        tableFSSFDialplan = new CFFswMySqlFSSFDialplanTable(this);
        tableFSSFDirectory = new CFFswMySqlFSSFDirectoryTable(this);
        tableFSSFExtension = new CFFswMySqlFSSFExtensionTable(this);
        tableFSSFGateway = new CFFswMySqlFSSFGatewayTable(this);
        tableFSSFProfile = new CFFswMySqlFSSFProfileTable(this);
        tableFSSFProfileAlias = new CFFswMySqlFSSFProfileAliasTable(this);
        tableFSSFProfileDomain = new CFFswMySqlFSSFProfileDomainTable(this);
        tableFSSFVMail = new CFFswMySqlFSSFVMailTable(this);
        tableFSSofia = new CFFswMySqlFSSofiaTable(this);
        tableHostNode = new CFFswMySqlHostNodeTable(this);
        tableISOCountry = new CFFswMySqlISOCountryTable(this);
        tableISOCountryCurrency = new CFFswMySqlISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFFswMySqlISOCountryLanguageTable(this);
        tableISOCurrency = new CFFswMySqlISOCurrencyTable(this);
        tableISOLanguage = new CFFswMySqlISOLanguageTable(this);
        tableISOTimezone = new CFFswMySqlISOTimezoneTable(this);
        tableMajorVersion = new CFFswMySqlMajorVersionTable(this);
        tableMimeType = new CFFswMySqlMimeTypeTable(this);
        tableMinorVersion = new CFFswMySqlMinorVersionTable(this);
        tablePbxIvrMenu = new CFFswMySqlPbxIvrMenuTable(this);
        tablePbxIvrMenuEntry = new CFFswMySqlPbxIvrMenuEntryTable(this);
        tableProjectBase = new CFFswMySqlProjectBaseTable(this);
        tableRealProject = new CFFswMySqlRealProjectTable(this);
        tableSecApp = new CFFswMySqlSecAppTable(this);
        tableSecDevice = new CFFswMySqlSecDeviceTable(this);
        tableSecForm = new CFFswMySqlSecFormTable(this);
        tableSecGroup = new CFFswMySqlSecGroupTable(this);
        tableSecGroupForm = new CFFswMySqlSecGroupFormTable(this);
        tableSecGroupInclude = new CFFswMySqlSecGroupIncludeTable(this);
        tableSecGroupMember = new CFFswMySqlSecGroupMemberTable(this);
        tableSecSession = new CFFswMySqlSecSessionTable(this);
        tableSecUser = new CFFswMySqlSecUserTable(this);
        tableService = new CFFswMySqlServiceTable(this);
        tableServiceType = new CFFswMySqlServiceTypeTable(this);
        tableSubProject = new CFFswMySqlSubProjectTable(this);
        tableTSecGroup = new CFFswMySqlTSecGroupTable(this);
        tableTSecGroupInclude = new CFFswMySqlTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFFswMySqlTSecGroupMemberTable(this);
        tableTenant = new CFFswMySqlTenantTable(this);
        tableTld = new CFFswMySqlTldTable(this);
        tableTopDomain = new CFFswMySqlTopDomainTable(this);
        tableTopProject = new CFFswMySqlTopProjectTable(this);
        tableURLProtocol = new CFFswMySqlURLProtocolTable(this);
        tableVersion = new CFFswMySqlVersionTable(this);
        setDbSchemaName(conf.getDbDatabase());
    }

    public CFFswMySqlSchema(String argJndiName) {
        super(argJndiName);
        cnx = null;
        inTransaction = false;
        tableAuditAction = new CFFswMySqlAuditActionTable(this);
        tableCluster = new CFFswMySqlClusterTable(this);
        tableDomain = new CFFswMySqlDomainTable(this);
        tableDomainBase = new CFFswMySqlDomainBaseTable(this);
        tableFSSFConference = new CFFswMySqlFSSFConferenceTable(this);
        tableFSSFConferenceProfile = new CFFswMySqlFSSFConferenceProfileTable(this);
        tableFSSFDialer = new CFFswMySqlFSSFDialerTable(this);
        tableFSSFDialplan = new CFFswMySqlFSSFDialplanTable(this);
        tableFSSFDirectory = new CFFswMySqlFSSFDirectoryTable(this);
        tableFSSFExtension = new CFFswMySqlFSSFExtensionTable(this);
        tableFSSFGateway = new CFFswMySqlFSSFGatewayTable(this);
        tableFSSFProfile = new CFFswMySqlFSSFProfileTable(this);
        tableFSSFProfileAlias = new CFFswMySqlFSSFProfileAliasTable(this);
        tableFSSFProfileDomain = new CFFswMySqlFSSFProfileDomainTable(this);
        tableFSSFVMail = new CFFswMySqlFSSFVMailTable(this);
        tableFSSofia = new CFFswMySqlFSSofiaTable(this);
        tableHostNode = new CFFswMySqlHostNodeTable(this);
        tableISOCountry = new CFFswMySqlISOCountryTable(this);
        tableISOCountryCurrency = new CFFswMySqlISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFFswMySqlISOCountryLanguageTable(this);
        tableISOCurrency = new CFFswMySqlISOCurrencyTable(this);
        tableISOLanguage = new CFFswMySqlISOLanguageTable(this);
        tableISOTimezone = new CFFswMySqlISOTimezoneTable(this);
        tableMajorVersion = new CFFswMySqlMajorVersionTable(this);
        tableMimeType = new CFFswMySqlMimeTypeTable(this);
        tableMinorVersion = new CFFswMySqlMinorVersionTable(this);
        tablePbxIvrMenu = new CFFswMySqlPbxIvrMenuTable(this);
        tablePbxIvrMenuEntry = new CFFswMySqlPbxIvrMenuEntryTable(this);
        tableProjectBase = new CFFswMySqlProjectBaseTable(this);
        tableRealProject = new CFFswMySqlRealProjectTable(this);
        tableSecApp = new CFFswMySqlSecAppTable(this);
        tableSecDevice = new CFFswMySqlSecDeviceTable(this);
        tableSecForm = new CFFswMySqlSecFormTable(this);
        tableSecGroup = new CFFswMySqlSecGroupTable(this);
        tableSecGroupForm = new CFFswMySqlSecGroupFormTable(this);
        tableSecGroupInclude = new CFFswMySqlSecGroupIncludeTable(this);
        tableSecGroupMember = new CFFswMySqlSecGroupMemberTable(this);
        tableSecSession = new CFFswMySqlSecSessionTable(this);
        tableSecUser = new CFFswMySqlSecUserTable(this);
        tableService = new CFFswMySqlServiceTable(this);
        tableServiceType = new CFFswMySqlServiceTypeTable(this);
        tableSubProject = new CFFswMySqlSubProjectTable(this);
        tableTSecGroup = new CFFswMySqlTSecGroupTable(this);
        tableTSecGroupInclude = new CFFswMySqlTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFFswMySqlTSecGroupMemberTable(this);
        tableTenant = new CFFswMySqlTenantTable(this);
        tableTld = new CFFswMySqlTldTable(this);
        tableTopDomain = new CFFswMySqlTopDomainTable(this);
        tableTopProject = new CFFswMySqlTopProjectTable(this);
        tableURLProtocol = new CFFswMySqlURLProtocolTable(this);
        tableVersion = new CFFswMySqlVersionTable(this);
    }

    public CFFswMySqlSchema(Connection argCnx) {
        super();
        cnx = argCnx;
        inTransaction = false;
        tableAuditAction = new CFFswMySqlAuditActionTable(this);
        tableCluster = new CFFswMySqlClusterTable(this);
        tableDomain = new CFFswMySqlDomainTable(this);
        tableDomainBase = new CFFswMySqlDomainBaseTable(this);
        tableFSSFConference = new CFFswMySqlFSSFConferenceTable(this);
        tableFSSFConferenceProfile = new CFFswMySqlFSSFConferenceProfileTable(this);
        tableFSSFDialer = new CFFswMySqlFSSFDialerTable(this);
        tableFSSFDialplan = new CFFswMySqlFSSFDialplanTable(this);
        tableFSSFDirectory = new CFFswMySqlFSSFDirectoryTable(this);
        tableFSSFExtension = new CFFswMySqlFSSFExtensionTable(this);
        tableFSSFGateway = new CFFswMySqlFSSFGatewayTable(this);
        tableFSSFProfile = new CFFswMySqlFSSFProfileTable(this);
        tableFSSFProfileAlias = new CFFswMySqlFSSFProfileAliasTable(this);
        tableFSSFProfileDomain = new CFFswMySqlFSSFProfileDomainTable(this);
        tableFSSFVMail = new CFFswMySqlFSSFVMailTable(this);
        tableFSSofia = new CFFswMySqlFSSofiaTable(this);
        tableHostNode = new CFFswMySqlHostNodeTable(this);
        tableISOCountry = new CFFswMySqlISOCountryTable(this);
        tableISOCountryCurrency = new CFFswMySqlISOCountryCurrencyTable(this);
        tableISOCountryLanguage = new CFFswMySqlISOCountryLanguageTable(this);
        tableISOCurrency = new CFFswMySqlISOCurrencyTable(this);
        tableISOLanguage = new CFFswMySqlISOLanguageTable(this);
        tableISOTimezone = new CFFswMySqlISOTimezoneTable(this);
        tableMajorVersion = new CFFswMySqlMajorVersionTable(this);
        tableMimeType = new CFFswMySqlMimeTypeTable(this);
        tableMinorVersion = new CFFswMySqlMinorVersionTable(this);
        tablePbxIvrMenu = new CFFswMySqlPbxIvrMenuTable(this);
        tablePbxIvrMenuEntry = new CFFswMySqlPbxIvrMenuEntryTable(this);
        tableProjectBase = new CFFswMySqlProjectBaseTable(this);
        tableRealProject = new CFFswMySqlRealProjectTable(this);
        tableSecApp = new CFFswMySqlSecAppTable(this);
        tableSecDevice = new CFFswMySqlSecDeviceTable(this);
        tableSecForm = new CFFswMySqlSecFormTable(this);
        tableSecGroup = new CFFswMySqlSecGroupTable(this);
        tableSecGroupForm = new CFFswMySqlSecGroupFormTable(this);
        tableSecGroupInclude = new CFFswMySqlSecGroupIncludeTable(this);
        tableSecGroupMember = new CFFswMySqlSecGroupMemberTable(this);
        tableSecSession = new CFFswMySqlSecSessionTable(this);
        tableSecUser = new CFFswMySqlSecUserTable(this);
        tableService = new CFFswMySqlServiceTable(this);
        tableServiceType = new CFFswMySqlServiceTypeTable(this);
        tableSubProject = new CFFswMySqlSubProjectTable(this);
        tableTSecGroup = new CFFswMySqlTSecGroupTable(this);
        tableTSecGroupInclude = new CFFswMySqlTSecGroupIncludeTable(this);
        tableTSecGroupMember = new CFFswMySqlTSecGroupMemberTable(this);
        tableTenant = new CFFswMySqlTenantTable(this);
        tableTld = new CFFswMySqlTldTable(this);
        tableTopDomain = new CFFswMySqlTopDomainTable(this);
        tableTopProject = new CFFswMySqlTopProjectTable(this);
        tableURLProtocol = new CFFswMySqlURLProtocolTable(this);
        tableVersion = new CFFswMySqlVersionTable(this);
        try {
            cnx.setAutoCommit(false);
            cnx.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
            cnx.rollback();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "CFFswMySqlSchema-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.mysql.jdbc.Driver");
            } catch (ClassNotFoundException e) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "connect",
                        "Could not load MySql 5.5 JDBC 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:mysql://" + 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.mysql.jdbc.Driver");
            } catch (ClassNotFoundException e) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "connect",
                        "Could not load MySql 5.5 JDBC driver", e);
            }
            String dbServer = configuration.getDbServer();
            int dbPort = configuration.getDbPort();
            String dbDatabase = configuration.getDbDatabase();
            String dbUserName = username;
            String dbPassword = password;
            String url = "jdbc:mysql://" + 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();
                    }
                    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(CFFswAuthorization Authorization) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            String sql = "SELECT " + getLowerDbSchemaName() + ".sp_is_system_user( ? ) as IsSystemUser";
            if (stmtSelectIsSystemUser == null) {
                stmtSelectIsSystemUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsSystemUser.setString(1, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsSystemUser.executeQuery();
            boolean resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getBoolean(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isSystemUser",
                        "Query of sp_is_system_user() did not return a result row");
            }
            resultSet.close();
            return (resultFlag);
        } 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(CFFswAuthorization Authorization, long clusterId, String groupName) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isClusterUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            String sql = "SELECT " + getLowerDbSchemaName() + ".sp_is_cluster_user( ?, ?, ? ) as IsClusterUser";
            if (stmtSelectIsClusterUser == null) {
                stmtSelectIsClusterUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsClusterUser.setLong(1, clusterId);
            stmtSelectIsClusterUser.setString(2, groupName);
            stmtSelectIsClusterUser.setString(3, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsClusterUser.executeQuery();
            boolean resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getBoolean(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isClusterUser",
                        "Query of sp_is_cluster_user() did not return a result row");
            }
            resultSet.close();
            return (resultFlag);
        } 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(CFFswAuthorization Authorization, long tenantId, String groupName) {
        if (!inTransaction) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isTenantUser",
                    "Not in a transaction");
        }
        ResultSet resultSet = null;
        try {
            String sql = "SELECT " + getLowerDbSchemaName() + ".sp_is_tenant_user( ?, ?, ? ) as IsTenantUser";
            if (stmtSelectIsTenantUser == null) {
                stmtSelectIsTenantUser = cnx.prepareStatement(sql);
            }
            stmtSelectIsTenantUser.setLong(1, tenantId);
            stmtSelectIsTenantUser.setString(2, groupName);
            stmtSelectIsTenantUser.setString(3, Authorization.getSecUserId().toString());
            resultSet = stmtSelectIsTenantUser.executeQuery();
            boolean resultFlag;
            if (resultSet.next()) {
                resultFlag = resultSet.getBoolean(1);
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isTenantUser",
                        "Query of sp_is_tenant_user() did not return a result row");
            }
            resultSet.close();
            return (resultFlag);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isTenantUser", e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void releasePreparedStatements() {
        if (stmtSelectIsSystemUser != null) {
            try {
                stmtSelectIsSystemUser.close();
            } catch (SQLException e) {
            }
            stmtSelectIsSystemUser = null;
        }
        if (stmtSelectIsClusterUser != null) {
            try {
                stmtSelectIsClusterUser.close();
            } catch (SQLException e) {
            }
            stmtSelectIsClusterUser = null;
        }
        if (stmtSelectIsTenantUser != null) {
            try {
                stmtSelectIsTenantUser.close();
            } catch (SQLException e) {
            }
            stmtSelectIsTenantUser = null;
        }
        if (stmtSelectNextServiceTypeIdGen != null) {
            try {
                stmtSelectNextServiceTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextServiceTypeIdGen = null;
        }
        if (stmtInsertNextServiceTypeIdGen != null) {
            try {
                stmtInsertNextServiceTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtInsertNextServiceTypeIdGen = null;
        }
        if (stmtUpdateNextServiceTypeIdGen != null) {
            try {
                stmtUpdateNextServiceTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtUpdateNextServiceTypeIdGen = null;
        }
        if (stmtSelectNextMimeTypeIdGen != null) {
            try {
                stmtSelectNextMimeTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextMimeTypeIdGen = null;
        }
        if (stmtInsertNextMimeTypeIdGen != null) {
            try {
                stmtInsertNextMimeTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtInsertNextMimeTypeIdGen = null;
        }
        if (stmtUpdateNextMimeTypeIdGen != null) {
            try {
                stmtUpdateNextMimeTypeIdGen.close();
            } catch (SQLException e) {
            }
            stmtUpdateNextMimeTypeIdGen = null;
        }
        if (stmtSelectNextClusterIdGen != null) {
            try {
                stmtSelectNextClusterIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextClusterIdGen = null;
        }
        if (stmtInsertNextClusterIdGen != null) {
            try {
                stmtInsertNextClusterIdGen.close();
            } catch (SQLException e) {
            }
            stmtInsertNextClusterIdGen = null;
        }
        if (stmtUpdateNextClusterIdGen != null) {
            try {
                stmtUpdateNextClusterIdGen.close();
            } catch (SQLException e) {
            }
            stmtUpdateNextClusterIdGen = null;
        }
        if (stmtSelectNextTenantIdGen != null) {
            try {
                stmtSelectNextTenantIdGen.close();
            } catch (SQLException e) {
            }
            stmtSelectNextTenantIdGen = null;
        }
        if (stmtInsertNextTenantIdGen != null) {
            try {
                stmtInsertNextTenantIdGen.close();
            } catch (SQLException e) {
            }
            stmtInsertNextTenantIdGen = null;
        }
        if (stmtUpdateNextTenantIdGen != null) {
            try {
                stmtUpdateNextTenantIdGen.close();
            } catch (SQLException e) {
            }
            stmtUpdateNextTenantIdGen = null;
        }
        if (tableAuditAction != null) {
            ((CFFswMySqlAuditActionTable) tableAuditAction).releasePreparedStatements();
        }
        if (tableCluster != null) {
            ((CFFswMySqlClusterTable) tableCluster).releasePreparedStatements();
        }
        if (tableDomain != null) {
            ((CFFswMySqlDomainTable) tableDomain).releasePreparedStatements();
        }
        if (tableDomainBase != null) {
            ((CFFswMySqlDomainBaseTable) tableDomainBase).releasePreparedStatements();
        }
        if (tableFSSFConference != null) {
            ((CFFswMySqlFSSFConferenceTable) tableFSSFConference).releasePreparedStatements();
        }
        if (tableFSSFConferenceProfile != null) {
            ((CFFswMySqlFSSFConferenceProfileTable) tableFSSFConferenceProfile).releasePreparedStatements();
        }
        if (tableFSSFDialer != null) {
            ((CFFswMySqlFSSFDialerTable) tableFSSFDialer).releasePreparedStatements();
        }
        if (tableFSSFDialplan != null) {
            ((CFFswMySqlFSSFDialplanTable) tableFSSFDialplan).releasePreparedStatements();
        }
        if (tableFSSFDirectory != null) {
            ((CFFswMySqlFSSFDirectoryTable) tableFSSFDirectory).releasePreparedStatements();
        }
        if (tableFSSFExtension != null) {
            ((CFFswMySqlFSSFExtensionTable) tableFSSFExtension).releasePreparedStatements();
        }
        if (tableFSSFGateway != null) {
            ((CFFswMySqlFSSFGatewayTable) tableFSSFGateway).releasePreparedStatements();
        }
        if (tableFSSFProfile != null) {
            ((CFFswMySqlFSSFProfileTable) tableFSSFProfile).releasePreparedStatements();
        }
        if (tableFSSFProfileAlias != null) {
            ((CFFswMySqlFSSFProfileAliasTable) tableFSSFProfileAlias).releasePreparedStatements();
        }
        if (tableFSSFProfileDomain != null) {
            ((CFFswMySqlFSSFProfileDomainTable) tableFSSFProfileDomain).releasePreparedStatements();
        }
        if (tableFSSFVMail != null) {
            ((CFFswMySqlFSSFVMailTable) tableFSSFVMail).releasePreparedStatements();
        }
        if (tableFSSofia != null) {
            ((CFFswMySqlFSSofiaTable) tableFSSofia).releasePreparedStatements();
        }
        if (tableHostNode != null) {
            ((CFFswMySqlHostNodeTable) tableHostNode).releasePreparedStatements();
        }
        if (tableISOCountry != null) {
            ((CFFswMySqlISOCountryTable) tableISOCountry).releasePreparedStatements();
        }
        if (tableISOCountryCurrency != null) {
            ((CFFswMySqlISOCountryCurrencyTable) tableISOCountryCurrency).releasePreparedStatements();
        }
        if (tableISOCountryLanguage != null) {
            ((CFFswMySqlISOCountryLanguageTable) tableISOCountryLanguage).releasePreparedStatements();
        }
        if (tableISOCurrency != null) {
            ((CFFswMySqlISOCurrencyTable) tableISOCurrency).releasePreparedStatements();
        }
        if (tableISOLanguage != null) {
            ((CFFswMySqlISOLanguageTable) tableISOLanguage).releasePreparedStatements();
        }
        if (tableISOTimezone != null) {
            ((CFFswMySqlISOTimezoneTable) tableISOTimezone).releasePreparedStatements();
        }
        if (tableMajorVersion != null) {
            ((CFFswMySqlMajorVersionTable) tableMajorVersion).releasePreparedStatements();
        }
        if (tableMimeType != null) {
            ((CFFswMySqlMimeTypeTable) tableMimeType).releasePreparedStatements();
        }
        if (tableMinorVersion != null) {
            ((CFFswMySqlMinorVersionTable) tableMinorVersion).releasePreparedStatements();
        }
        if (tablePbxIvrMenu != null) {
            ((CFFswMySqlPbxIvrMenuTable) tablePbxIvrMenu).releasePreparedStatements();
        }
        if (tablePbxIvrMenuEntry != null) {
            ((CFFswMySqlPbxIvrMenuEntryTable) tablePbxIvrMenuEntry).releasePreparedStatements();
        }
        if (tableProjectBase != null) {
            ((CFFswMySqlProjectBaseTable) tableProjectBase).releasePreparedStatements();
        }
        if (tableRealProject != null) {
            ((CFFswMySqlRealProjectTable) tableRealProject).releasePreparedStatements();
        }
        if (tableSecApp != null) {
            ((CFFswMySqlSecAppTable) tableSecApp).releasePreparedStatements();
        }
        if (tableSecDevice != null) {
            ((CFFswMySqlSecDeviceTable) tableSecDevice).releasePreparedStatements();
        }
        if (tableSecForm != null) {
            ((CFFswMySqlSecFormTable) tableSecForm).releasePreparedStatements();
        }
        if (tableSecGroup != null) {
            ((CFFswMySqlSecGroupTable) tableSecGroup).releasePreparedStatements();
        }
        if (tableSecGroupForm != null) {
            ((CFFswMySqlSecGroupFormTable) tableSecGroupForm).releasePreparedStatements();
        }
        if (tableSecGroupInclude != null) {
            ((CFFswMySqlSecGroupIncludeTable) tableSecGroupInclude).releasePreparedStatements();
        }
        if (tableSecGroupMember != null) {
            ((CFFswMySqlSecGroupMemberTable) tableSecGroupMember).releasePreparedStatements();
        }
        if (tableSecSession != null) {
            ((CFFswMySqlSecSessionTable) tableSecSession).releasePreparedStatements();
        }
        if (tableSecUser != null) {
            ((CFFswMySqlSecUserTable) tableSecUser).releasePreparedStatements();
        }
        if (tableService != null) {
            ((CFFswMySqlServiceTable) tableService).releasePreparedStatements();
        }
        if (tableServiceType != null) {
            ((CFFswMySqlServiceTypeTable) tableServiceType).releasePreparedStatements();
        }
        if (tableSubProject != null) {
            ((CFFswMySqlSubProjectTable) tableSubProject).releasePreparedStatements();
        }
        if (tableTSecGroup != null) {
            ((CFFswMySqlTSecGroupTable) tableTSecGroup).releasePreparedStatements();
        }
        if (tableTSecGroupInclude != null) {
            ((CFFswMySqlTSecGroupIncludeTable) tableTSecGroupInclude).releasePreparedStatements();
        }
        if (tableTSecGroupMember != null) {
            ((CFFswMySqlTSecGroupMemberTable) tableTSecGroupMember).releasePreparedStatements();
        }
        if (tableTenant != null) {
            ((CFFswMySqlTenantTable) tableTenant).releasePreparedStatements();
        }
        if (tableTld != null) {
            ((CFFswMySqlTldTable) tableTld).releasePreparedStatements();
        }
        if (tableTopDomain != null) {
            ((CFFswMySqlTopDomainTable) tableTopDomain).releasePreparedStatements();
        }
        if (tableTopProject != null) {
            ((CFFswMySqlTopProjectTable) tableTopProject).releasePreparedStatements();
        }
        if (tableURLProtocol != null) {
            ((CFFswMySqlURLProtocolTable) tableURLProtocol).releasePreparedStatements();
        }
        if (tableVersion != null) {
            ((CFFswMySqlVersionTable) tableVersion).releasePreparedStatements();
        }
    }

    public int nextServiceTypeIdGen() {
        final String S_ProcName = "nextServiceTypeIdGen";
        String sqlSelectNextIdGen = "SELECT " + getLowerDbSchemaName()
                + ".sp_next_servicetypeidgen() as NextServiceTypeIdGen;";
        if (!isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet rsSelect = null;
        try {
            Connection cnx = getCnx();
            if (stmtSelectNextServiceTypeIdGen == null) {
                stmtSelectNextServiceTypeIdGen = cnx.prepareStatement(sqlSelectNextIdGen);
            }
            int nextId;
            rsSelect = stmtSelectNextServiceTypeIdGen.executeQuery();
            if (rsSelect.next()) {
                nextId = rsSelect.getInt(1);
                if (rsSelect.wasNull()) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "next_id cannot be null!");
                }
                if (rsSelect.next()) {
                    rsSelect.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-buff select response, " + rsSelect.getRow() + " rows selected");
                }
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected 1 row to be returned by invoking " + getLowerDbSchemaName()
                                + ".sp_next_servicetypeidgen()");
            }
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (rsSelect != null) {
                try {
                    rsSelect.close();
                } catch (SQLException e) {
                }
                rsSelect = null;
            }
        }
    }

    public int nextMimeTypeIdGen() {
        final String S_ProcName = "nextMimeTypeIdGen";
        String sqlSelectNextIdGen = "SELECT " + getLowerDbSchemaName()
                + ".sp_next_mimetypeidgen() as NextMimeTypeIdGen;";
        if (!isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet rsSelect = null;
        try {
            Connection cnx = getCnx();
            if (stmtSelectNextMimeTypeIdGen == null) {
                stmtSelectNextMimeTypeIdGen = cnx.prepareStatement(sqlSelectNextIdGen);
            }
            int nextId;
            rsSelect = stmtSelectNextMimeTypeIdGen.executeQuery();
            if (rsSelect.next()) {
                nextId = rsSelect.getInt(1);
                if (rsSelect.wasNull()) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "next_id cannot be null!");
                }
                if (rsSelect.next()) {
                    rsSelect.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-buff select response, " + rsSelect.getRow() + " rows selected");
                }
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected 1 row to be returned by invoking " + getLowerDbSchemaName()
                                + ".sp_next_mimetypeidgen()");
            }
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (rsSelect != null) {
                try {
                    rsSelect.close();
                } catch (SQLException e) {
                }
                rsSelect = null;
            }
        }
    }

    public long nextClusterIdGen() {
        final String S_ProcName = "nextClusterIdGen";
        String sqlSelectNextIdGen = "SELECT " + getLowerDbSchemaName()
                + ".sp_next_clusteridgen() as NextClusterIdGen;";
        if (!isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet rsSelect = null;
        try {
            Connection cnx = getCnx();
            if (stmtSelectNextClusterIdGen == null) {
                stmtSelectNextClusterIdGen = cnx.prepareStatement(sqlSelectNextIdGen);
            }
            long nextId;
            rsSelect = stmtSelectNextClusterIdGen.executeQuery();
            if (rsSelect.next()) {
                nextId = rsSelect.getLong(1);
                if (rsSelect.wasNull()) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "next_id cannot be null!");
                }
                if (rsSelect.next()) {
                    rsSelect.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-buff select response, " + rsSelect.getRow() + " rows selected");
                }
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected 1 row to be returned by invoking " + getLowerDbSchemaName()
                                + ".sp_next_clusteridgen()");
            }
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (rsSelect != null) {
                try {
                    rsSelect.close();
                } catch (SQLException e) {
                }
                rsSelect = null;
            }
        }
    }

    public long nextTenantIdGen() {
        final String S_ProcName = "nextTenantIdGen";
        String sqlSelectNextIdGen = "SELECT " + getLowerDbSchemaName()
                + ".sp_next_tenantidgen() as NextTenantIdGen;";
        if (!isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet rsSelect = null;
        try {
            Connection cnx = getCnx();
            if (stmtSelectNextTenantIdGen == null) {
                stmtSelectNextTenantIdGen = cnx.prepareStatement(sqlSelectNextIdGen);
            }
            long nextId;
            rsSelect = stmtSelectNextTenantIdGen.executeQuery();
            if (rsSelect.next()) {
                nextId = rsSelect.getLong(1);
                if (rsSelect.wasNull()) {
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "next_id cannot be null!");
                }
                if (rsSelect.next()) {
                    rsSelect.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-buff select response, " + rsSelect.getRow() + " rows selected");
                }
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected 1 row to be returned by invoking " + getLowerDbSchemaName()
                                + ".sp_next_tenantidgen()");
            }
            return (nextId);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (rsSelect != null) {
                try {
                    rsSelect.close();
                } catch (SQLException e) {
                }
                rsSelect = null;
            }
        }
    }

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

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

    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(CFFswMySqlSchema.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 ("true");
            } else {
                return ("false");
            }
        }
    }

    public static String getBoolString(boolean val) {
        if (val) {
            return ("true");
        } else {
            return ("false");
        }
    }

    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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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(CFFswMySqlSchema.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));
        }
    }
}