net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlSecSessionTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql.CFAccMySqlSecSessionTable.java

Source

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

/*
 *   MSS Code Factory Accounting Business Application 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.0-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and
 *      CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 1.11
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 1.11 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfacc.v2_0.CFAccMySql;

import java.math.*;
import java.sql.*;
import java.text.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.*;

/*
 *   CFAccMySqlSecSessionTable MySQL Jdbc DbIO implementation
 *   for SecSession.
 */
public class CFAccMySqlSecSessionTable implements ICFAccSecSessionTable {
    private CFAccMySqlSchema schema;
    protected PreparedStatement stmtReadBuffByPKey = null;
    protected PreparedStatement stmtLockBuffByPKey = null;
    protected PreparedStatement stmtCreateByPKey = null;
    protected PreparedStatement stmtUpdateByPKey = null;
    protected PreparedStatement stmtDeleteByPKey = null;
    protected PreparedStatement stmtReadAllBuff = null;
    protected PreparedStatement stmtReadBuffByIdIdx = null;
    protected PreparedStatement stmtReadBuffBySecUserIdx = null;
    protected PreparedStatement stmtReadBuffByStartIdx = null;
    protected PreparedStatement stmtReadBuffByFinishIdx = null;
    protected PreparedStatement stmtDeleteByIdIdx = null;
    protected PreparedStatement stmtDeleteBySecUserIdx = null;
    protected PreparedStatement stmtDeleteByStartIdx = null;
    protected PreparedStatement stmtDeleteByFinishIdx = null;

    public CFAccMySqlSecSessionTable(CFAccMySqlSchema argSchema) {
        schema = argSchema;
    }

    public void createSecSession(CFAccAuthorization Authorization, CFAccSecSessionBuff Buff) {
        final String S_ProcName = "createSecSession";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            UUID SecUserId = Buff.getRequiredSecUserId();
            Calendar Start = Buff.getRequiredStart();
            Calendar Finish = Buff.getOptionalFinish();

            UUID SecSessionId = UUID.randomUUID();
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_secsess( ?, ?, ?, ?, ?, ?" + ", "
                    + "?" + ", " + "?" + ", " + "timestamp( ? )" + ", " + "timestamp( ? )" + " )";
            if (stmtCreateByPKey == null) {
                stmtCreateByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtCreateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtCreateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtCreateByPKey.setString(argIdx++, "SESS");
            stmtCreateByPKey.setString(argIdx++, SecSessionId.toString());
            stmtCreateByPKey.setString(argIdx++, SecUserId.toString());
            stmtCreateByPKey.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Start));
            if (Finish != null) {
                stmtCreateByPKey.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Finish));
            } else {
                stmtCreateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            try {
                resultSet = stmtCreateByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff createdBuff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredSecSessionId(createdBuff.getRequiredSecSessionId());
                Buff.setRequiredSecUserId(createdBuff.getRequiredSecUserId());
                Buff.setRequiredStart(createdBuff.getRequiredStart());
                Buff.setOptionalFinish(createdBuff.getOptionalFinish());
                Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected a single-record response, " + resultSet.getRow() + " rows selected");
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    protected static String S_sqlSelectSecSessionDistinctClassCode = null;

    public String getSqlSelectSecSessionDistinctClassCode() {
        if (S_sqlSelectSecSessionDistinctClassCode == null) {
            S_sqlSelectSecSessionDistinctClassCode = "SELECT " + "DISTINCT sess.ClassCode " + "FROM "
                    + schema.getLowerSchemaDbName() + ".SecSess AS sess ";
        }
        return (S_sqlSelectSecSessionDistinctClassCode);
    }

    protected static String S_sqlSelectSecSessionBuff = null;

    public String getSqlSelectSecSessionBuff() {
        if (S_sqlSelectSecSessionBuff == null) {
            S_sqlSelectSecSessionBuff = "SELECT " + "sess.SecSessionId, " + "sess.SecUserId, "
                    + "date_format( sess.start_ts, '%Y-%m-%d %H:%i:%S' ) as start_ts, "
                    + "date_format( sess.finish_ts, '%Y-%m-%d %H:%i:%S' ) as finish_ts, " + "sess.Revision "
                    + "FROM " + schema.getLowerSchemaDbName() + ".SecSess AS sess ";
        }
        return (S_sqlSelectSecSessionBuff);
    }

    protected CFAccSecSessionBuff unpackSecSessionResultSetToBuff(ResultSet resultSet) throws SQLException {
        final String S_ProcName = "unpackSecSessionResultSetToBuff";
        int idxcol = 1;
        CFAccSecSessionBuff buff = schema.getFactorySecSession().newBuff();
        buff.setRequiredSecSessionId(CFAccMySqlSchema.convertUuidString(resultSet.getString(idxcol)));
        idxcol++;
        buff.setRequiredSecUserId(CFAccMySqlSchema.convertUuidString(resultSet.getString(idxcol)));
        idxcol++;
        buff.setRequiredStart(CFAccMySqlSchema.convertTimestampString(resultSet.getString(idxcol)));
        idxcol++;
        {
            Calendar colVal = CFAccMySqlSchema.convertTimestampString(resultSet.getString(idxcol));
            if (resultSet.wasNull()) {
                buff.setOptionalFinish(null);
            } else {
                buff.setOptionalFinish(colVal);
            }
        }
        idxcol++;

        buff.setRequiredRevision(resultSet.getInt(idxcol));
        return (buff);
    }

    public CFAccSecSessionBuff readDerived(CFAccAuthorization Authorization, CFAccSecSessionPKey PKey) {
        final String S_ProcName = "readDerived";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFAccSecSessionBuff buff;
        buff = readBuff(Authorization, PKey);
        return (buff);
    }

    public CFAccSecSessionBuff lockDerived(CFAccAuthorization Authorization, CFAccSecSessionPKey PKey) {
        final String S_ProcName = "lockDerived";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFAccSecSessionBuff buff;
        buff = lockBuff(Authorization, PKey);
        return (buff);
    }

    public CFAccSecSessionBuff[] readAllDerived(CFAccAuthorization Authorization) {
        final String S_ProcName = "readAllDerived";
        CFAccSecSessionBuff[] buffArray;
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        buffArray = readAllBuff(Authorization);
        return (buffArray);
    }

    public CFAccSecSessionBuff readDerivedByIdIdx(CFAccAuthorization Authorization, UUID SecSessionId) {
        final String S_ProcName = "CFAccMySqlSecSessionTable.readDerivedByIdIdx() ";
        CFAccSecSessionBuff buff;
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        buff = readBuffByIdIdx(Authorization, SecSessionId);
        return (buff);
    }

    public CFAccSecSessionBuff[] readDerivedBySecUserIdx(CFAccAuthorization Authorization, UUID SecUserId) {
        final String S_ProcName = "readDerivedBySecUserIdx";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFAccSecSessionBuff[] buffList = readBuffBySecUserIdx(Authorization, SecUserId);
        return (buffList);

    }

    public CFAccSecSessionBuff readDerivedByStartIdx(CFAccAuthorization Authorization, UUID SecUserId,
            Calendar Start) {
        final String S_ProcName = "CFAccMySqlSecSessionTable.readDerivedByStartIdx() ";
        CFAccSecSessionBuff buff;
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        buff = readBuffByStartIdx(Authorization, SecUserId, Start);
        return (buff);
    }

    public CFAccSecSessionBuff[] readDerivedByFinishIdx(CFAccAuthorization Authorization, UUID SecUserId,
            Calendar Finish) {
        final String S_ProcName = "readDerivedByFinishIdx";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        CFAccSecSessionBuff[] buffList = readBuffByFinishIdx(Authorization, SecUserId, Finish);
        return (buffList);

    }

    public CFAccSecSessionBuff readBuff(CFAccAuthorization Authorization, CFAccSecSessionPKey PKey) {
        final String S_ProcName = "readBuff";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            UUID SecSessionId = PKey.getRequiredSecSessionId();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess( ?, ?, ?, ?, ?" + ", " + "?"
                    + " )";
            if (stmtReadBuffByPKey == null) {
                stmtReadBuffByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByPKey.setString(argIdx++, SecSessionId.toString());
            try {
                resultSet = stmtReadBuffByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff lockBuff(CFAccAuthorization Authorization, CFAccSecSessionPKey PKey) {
        final String S_ProcName = "lockBuff";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            UUID SecSessionId = PKey.getRequiredSecSessionId();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_lock_secsess( ?, ?, ?, ?, ?" + ", " + "?"
                    + " )";
            if (stmtLockBuffByPKey == null) {
                stmtLockBuffByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtLockBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtLockBuffByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtLockBuffByPKey.setString(argIdx++, SecSessionId.toString());
            try {
                resultSet = stmtLockBuffByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff[] readAllBuff(CFAccAuthorization Authorization) {
        final String S_ProcName = "readAllBuff";
        if (!schema.isTransactionOpen()) {
            throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                    "Transaction not open");
        }
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess_all( ?, ?, ?, ?, ? )";
            if (stmtReadAllBuff == null) {
                stmtReadAllBuff = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadAllBuff.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadAllBuff.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            try {
                resultSet = stmtReadAllBuff.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFAccSecSessionBuff> buffList = new LinkedList<CFAccSecSessionBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFAccSecSessionBuff[] retBuff = new CFAccSecSessionBuff[buffList.size()];
            Iterator<CFAccSecSessionBuff> iter = buffList.iterator();
            while (iter.hasNext()) {
                retBuff[idx++] = iter.next();
            }
            return (retBuff);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff readBuffByIdIdx(CFAccAuthorization Authorization, UUID SecSessionId) {
        final String S_ProcName = "readBuffByIdIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess_by_ididx( ?, ?, ?, ?, ?" + ", "
                    + "?" + " )";
            if (stmtReadBuffByIdIdx == null) {
                stmtReadBuffByIdIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByIdIdx.setString(argIdx++, SecSessionId.toString());
            try {
                resultSet = stmtReadBuffByIdIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff[] readBuffBySecUserIdx(CFAccAuthorization Authorization, UUID SecUserId) {
        final String S_ProcName = "readBuffBySecUserIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess_by_secuseridx( ?, ?, ?, ?, ?"
                    + ", " + "?" + " )";
            if (stmtReadBuffBySecUserIdx == null) {
                stmtReadBuffBySecUserIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffBySecUserIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffBySecUserIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffBySecUserIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffBySecUserIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffBySecUserIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffBySecUserIdx.setString(argIdx++, SecUserId.toString());
            try {
                resultSet = stmtReadBuffBySecUserIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFAccSecSessionBuff> buffList = new LinkedList<CFAccSecSessionBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFAccSecSessionBuff[] retBuff = new CFAccSecSessionBuff[buffList.size()];
            Iterator<CFAccSecSessionBuff> iter = buffList.iterator();
            while (iter.hasNext()) {
                retBuff[idx++] = iter.next();
            }
            return (retBuff);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff readBuffByStartIdx(CFAccAuthorization Authorization, UUID SecUserId,
            Calendar Start) {
        final String S_ProcName = "readBuffByStartIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess_by_startidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "timestamp( ? )" + " )";
            if (stmtReadBuffByStartIdx == null) {
                stmtReadBuffByStartIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByStartIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByStartIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByStartIdx.setString(argIdx++, SecUserId.toString());
            stmtReadBuffByStartIdx.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Start));
            try {
                resultSet = stmtReadBuffByStartIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                return (buff);
            } else {
                return (null);
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public CFAccSecSessionBuff[] readBuffByFinishIdx(CFAccAuthorization Authorization, UUID SecUserId,
            Calendar Finish) {
        final String S_ProcName = "readBuffByFinishIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_read_secsess_by_finishidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "timestamp( ? )" + " )";
            if (stmtReadBuffByFinishIdx == null) {
                stmtReadBuffByFinishIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtReadBuffByFinishIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByFinishIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtReadBuffByFinishIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtReadBuffByFinishIdx.setLong(argIdx++,
                    (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtReadBuffByFinishIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtReadBuffByFinishIdx.setString(argIdx++, SecUserId.toString());
            if (Finish != null) {
                stmtReadBuffByFinishIdx.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Finish));
            } else {
                stmtReadBuffByFinishIdx.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            try {
                resultSet = stmtReadBuffByFinishIdx.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            List<CFAccSecSessionBuff> buffList = new LinkedList<CFAccSecSessionBuff>();
            while ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
                buffList.add(buff);
            }
            int idx = 0;
            CFAccSecSessionBuff[] retBuff = new CFAccSecSessionBuff[buffList.size()];
            Iterator<CFAccSecSessionBuff> iter = buffList.iterator();
            while (iter.hasNext()) {
                retBuff[idx++] = iter.next();
            }
            return (retBuff);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void updateSecSession(CFAccAuthorization Authorization, CFAccSecSessionBuff Buff) {
        final String S_ProcName = "updateSecSession";
        ResultSet resultSet = null;
        try {
            UUID SecSessionId = Buff.getRequiredSecSessionId();
            UUID SecUserId = Buff.getRequiredSecUserId();
            Calendar Start = Buff.getRequiredStart();
            Calendar Finish = Buff.getOptionalFinish();
            int Revision = Buff.getRequiredRevision();
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_update_secsess( ?, ?, ?, ?, ?, ?" + ", "
                    + "?" + ", " + "?" + ", " + "timestamp( ? )" + ", " + "timestamp( ? )" + ", " + "?" + " )";
            if (stmtUpdateByPKey == null) {
                stmtUpdateByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtUpdateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtUpdateByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtUpdateByPKey.setString(argIdx++, "SESS");
            stmtUpdateByPKey.setString(argIdx++, SecSessionId.toString());
            stmtUpdateByPKey.setString(argIdx++, SecUserId.toString());
            stmtUpdateByPKey.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Start));
            if (Finish != null) {
                stmtUpdateByPKey.setString(argIdx++, CFAccMySqlSchema.getTimestampString(Finish));
            } else {
                stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            stmtUpdateByPKey.setInt(argIdx++, Revision);
            try {
                resultSet = stmtUpdateByPKey.executeQuery();
            } catch (SQLException e) {
                if (e.getErrorCode() != 1329) {
                    throw e;
                }
                resultSet = null;
            }
            if ((resultSet != null) && resultSet.next()) {
                CFAccSecSessionBuff updatedBuff = unpackSecSessionResultSetToBuff(resultSet);
                if ((resultSet != null) && resultSet.next()) {
                    resultSet.last();
                    throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                            "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
                }
                Buff.setRequiredSecUserId(updatedBuff.getRequiredSecUserId());
                Buff.setRequiredStart(updatedBuff.getRequiredStart());
                Buff.setOptionalFinish(updatedBuff.getOptionalFinish());
                Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
            } else {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Expected a single-record response, " + resultSet.getRow() + " rows selected");
            }
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSession(CFAccAuthorization Authorization, CFAccSecSessionBuff Buff) {
        final String S_ProcName = "deleteSecSession";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            UUID SecSessionId = Buff.getRequiredSecSessionId();

            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_secsess( ?, ?, ?, ?, ?" + ", " + "?"
                    + ", " + "?" + " )";
            if (stmtDeleteByPKey == null) {
                stmtDeleteByPKey = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByPKey.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByPKey.setString(argIdx++, SecSessionId.toString());
            stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
            ;
            stmtDeleteByPKey.executeUpdate();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSessionByIdIdx(CFAccAuthorization Authorization, UUID argSecSessionId) {
        final String S_ProcName = "deleteSecSessionByIdIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_secsess_by_ididx( ?, ?, ?, ?, ?"
                    + ", " + "?" + " )";
            if (stmtDeleteByIdIdx == null) {
                stmtDeleteByIdIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByIdIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByIdIdx.setString(argIdx++, argSecSessionId.toString());
            stmtDeleteByIdIdx.executeUpdate();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSessionByIdIdx(CFAccAuthorization Authorization, CFAccSecSessionPKey argKey) {
        deleteSecSessionByIdIdx(Authorization, argKey.getRequiredSecSessionId());
    }

    public void deleteSecSessionBySecUserIdx(CFAccAuthorization Authorization, UUID argSecUserId) {
        final String S_ProcName = "deleteSecSessionBySecUserIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_secsess_by_secuseridx( ?, ?, ?, ?, ?"
                    + ", " + "?" + " )";
            if (stmtDeleteBySecUserIdx == null) {
                stmtDeleteBySecUserIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteBySecUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteBySecUserIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteBySecUserIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteBySecUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteBySecUserIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteBySecUserIdx.setString(argIdx++, argSecUserId.toString());
            stmtDeleteBySecUserIdx.executeUpdate();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSessionBySecUserIdx(CFAccAuthorization Authorization,
            CFAccSecSessionBySecUserIdxKey argKey) {
        deleteSecSessionBySecUserIdx(Authorization, argKey.getRequiredSecUserId());
    }

    public void deleteSecSessionByStartIdx(CFAccAuthorization Authorization, UUID argSecUserId, Calendar argStart) {
        final String S_ProcName = "deleteSecSessionByStartIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_secsess_by_startidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "timestamp( ? )" + " )";
            if (stmtDeleteByStartIdx == null) {
                stmtDeleteByStartIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByStartIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByStartIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByStartIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByStartIdx.setString(argIdx++, argSecUserId.toString());
            stmtDeleteByStartIdx.setString(argIdx++, CFAccMySqlSchema.getTimestampString(argStart));
            stmtDeleteByStartIdx.executeUpdate();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSessionByStartIdx(CFAccAuthorization Authorization, CFAccSecSessionByStartIdxKey argKey) {
        deleteSecSessionByStartIdx(Authorization, argKey.getRequiredSecUserId(), argKey.getRequiredStart());
    }

    public void deleteSecSessionByFinishIdx(CFAccAuthorization Authorization, UUID argSecUserId,
            Calendar argFinish) {
        final String S_ProcName = "deleteSecSessionByFinishIdx";
        ResultSet resultSet = null;
        try {
            Connection cnx = schema.getCnx();
            String sql = "call " + schema.getLowerSchemaDbName() + ".sp_delete_secsess_by_finishidx( ?, ?, ?, ?, ?"
                    + ", " + "?" + ", " + "timestamp( ? )" + " )";
            if (stmtDeleteByFinishIdx == null) {
                stmtDeleteByFinishIdx = cnx.prepareStatement(sql);
            }
            int argIdx = 1;
            stmtDeleteByFinishIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByFinishIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecUserId().toString());
            stmtDeleteByFinishIdx.setString(argIdx++,
                    (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
            stmtDeleteByFinishIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
            stmtDeleteByFinishIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
            stmtDeleteByFinishIdx.setString(argIdx++, argSecUserId.toString());
            if (argFinish != null) {
                stmtDeleteByFinishIdx.setString(argIdx++, CFAccMySqlSchema.getTimestampString(argFinish));
            } else {
                stmtDeleteByFinishIdx.setNull(argIdx++, java.sql.Types.VARCHAR);
            }
            stmtDeleteByFinishIdx.executeUpdate();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        } finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                } catch (SQLException e) {
                }
                resultSet = null;
            }
        }
    }

    public void deleteSecSessionByFinishIdx(CFAccAuthorization Authorization,
            CFAccSecSessionByFinishIdxKey argKey) {
        deleteSecSessionByFinishIdx(Authorization, argKey.getRequiredSecUserId(), argKey.getOptionalFinish());
    }

    public CFAccCursor openSecSessionCursorAll(CFAccAuthorization Authorization) {
        String sql = getSqlSelectSecSessionBuff() + "ORDER BY " + "sess.SecSessionId ASC";
        CFAccCursor cursor = new CFAccMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public CFAccCursor openSecSessionCursorBySecUserIdx(CFAccAuthorization Authorization, UUID SecUserId) {
        String sql = getSqlSelectSecSessionBuff() + "WHERE " + "sess.SecUserId = '" + SecUserId.toString() + "' "
                + "ORDER BY " + "sess.SecSessionId ASC";
        CFAccCursor cursor = new CFAccMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public CFAccCursor openSecSessionCursorByFinishIdx(CFAccAuthorization Authorization, UUID SecUserId,
            Calendar Finish) {
        String sql = getSqlSelectSecSessionBuff() + "WHERE " + "sess.SecUserId = '" + SecUserId.toString() + "' "
                + "AND "
                + ((Finish == null) ? "sess.finish_ts is null "
                        : "sess.finish_ts = timestamp( " + CFAccMySqlSchema.getTimestampString(Finish) + " ) ")

                + "ORDER BY " + "sess.SecSessionId ASC";
        CFAccCursor cursor = new CFAccMySqlCursor(Authorization, schema, sql);
        return (cursor);
    }

    public void closeSecSessionCursor(CFAccCursor Cursor) {
        try {
            Cursor.getResultSet().close();
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeSecSessionCursor", e);
        }
    }

    public CFAccSecSessionBuff nextSecSessionCursor(CFAccCursor Cursor) {
        final String S_ProcName = "nextSecSessionCursor";
        try {
            ResultSet resultSet = Cursor.getResultSet();
            if (!resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "No more results available");
            }
            CFAccSecSessionBuff buff = unpackSecSessionResultSetToBuff(resultSet);
            return (buff);
        } catch (SQLException e) {
            throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
    }

    public CFAccSecSessionBuff prevSecSessionCursor(CFAccCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFAccSecSessionBuff buff = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextSecSessionCursor(Cursor);
        }
        return (buff);
    }

    public CFAccSecSessionBuff firstSecSessionCursor(CFAccCursor Cursor) {
        int targetRowIdx = 1;
        CFAccSecSessionBuff buff = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextSecSessionCursor(Cursor);
        }
        return (buff);
    }

    public CFAccSecSessionBuff lastSecSessionCursor(CFAccCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecSessionCursor");
    }

    public CFAccSecSessionBuff nthSecSessionCursor(CFAccCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFAccSecSessionBuff buff = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            buff = nextSecSessionCursor(Cursor);
        }
        return (buff);
    }

    /**
     *   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() {
        S_sqlSelectSecSessionDistinctClassCode = null;
        S_sqlSelectSecSessionBuff = null;
        if (stmtReadBuffByPKey != null) {
            try {
                stmtReadBuffByPKey.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByPKey = null;
        }
        if (stmtLockBuffByPKey != null) {
            try {
                stmtLockBuffByPKey.close();
            } catch (SQLException e) {
            }
            stmtLockBuffByPKey = null;
        }
        if (stmtCreateByPKey != null) {
            try {
                stmtCreateByPKey.close();
            } catch (SQLException e) {
            }
            stmtCreateByPKey = null;
        }
        if (stmtUpdateByPKey != null) {
            try {
                stmtUpdateByPKey.close();
            } catch (SQLException e) {
            }
            stmtUpdateByPKey = null;
        }
        if (stmtDeleteByPKey != null) {
            try {
                stmtDeleteByPKey.close();
            } catch (SQLException e) {
            }
            stmtDeleteByPKey = null;
        }
        if (stmtDeleteByIdIdx != null) {
            try {
                stmtDeleteByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByIdIdx = null;
        }
        if (stmtDeleteBySecUserIdx != null) {
            try {
                stmtDeleteBySecUserIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteBySecUserIdx = null;
        }
        if (stmtDeleteByStartIdx != null) {
            try {
                stmtDeleteByStartIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByStartIdx = null;
        }
        if (stmtDeleteByFinishIdx != null) {
            try {
                stmtDeleteByFinishIdx.close();
            } catch (SQLException e) {
            }
            stmtDeleteByFinishIdx = null;
        }
        if (stmtReadAllBuff != null) {
            try {
                stmtReadAllBuff.close();
            } catch (SQLException e) {
            }
            stmtReadAllBuff = null;
        }
        if (stmtReadBuffByIdIdx != null) {
            try {
                stmtReadBuffByIdIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByIdIdx = null;
        }
        if (stmtReadBuffBySecUserIdx != null) {
            try {
                stmtReadBuffBySecUserIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffBySecUserIdx = null;
        }
        if (stmtReadBuffByStartIdx != null) {
            try {
                stmtReadBuffByStartIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByStartIdx = null;
        }
        if (stmtReadBuffByFinishIdx != null) {
            try {
                stmtReadBuffByFinishIdx.close();
            } catch (SQLException e) {
            }
            stmtReadBuffByFinishIdx = null;
        }
    }
}