Example usage for java.sql SQLException getErrorCode

List of usage examples for java.sql SQLException getErrorCode

Introduction

In this page you can find the example usage for java.sql SQLException getErrorCode.

Prototype

public int getErrorCode() 

Source Link

Document

Retrieves the vendor-specific exception code for this SQLException object.

Usage

From source file:net.sourceforge.msscodefactory.cfinternet.v2_0.CFInternetMySql.CFInternetMySqlMimeTypeTable.java

public void createMimeType(CFInternetAuthorization Authorization, CFInternetMimeTypeBuff Buff) {
    final String S_ProcName = "createMimeType";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  w  w  w . j  ava  2s  . co m
    ResultSet resultSet = null;
    try {
        String Name = Buff.getRequiredName();
        String Description = Buff.getRequiredDescription();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerSchemaDbName() + ".sp_create_mimetype( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + " )";
        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++, "MIME");
        stmtCreateByPKey.setString(argIdx++, Name);
        stmtCreateByPKey.setString(argIdx++, Description);
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFInternetMimeTypeBuff createdBuff = unpackMimeTypeResultSetToBuff(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.setRequiredMimeTypeId(createdBuff.getRequiredMimeTypeId());
            Buff.setRequiredName(createdBuff.getRequiredName());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            Buff.setRequiredRevision(createdBuff.getRequiredRevision());
            Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
            Buff.setCreatedAt(createdBuff.getCreatedAt());
            Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
            Buff.setUpdatedAt(createdBuff.getUpdatedAt());
        } 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlAuditActionTable.java

public CFEnSyntaxAuditActionBuff readBuff(CFEnSyntaxAuthorization Authorization,
        CFEnSyntaxAuditActionPKey PKey) {
    final String S_ProcName = "readBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//w  w  w.  j a  v  a 2s  .co m
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        short AuditActionId = PKey.getRequiredAuditActionId();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_auditaction( ?, ?, ?, ?, ?" + ", "
                + "?" + " )";
        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.setShort(argIdx++, AuditActionId);
        try {
            resultSet = stmtReadBuffByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxAuditActionBuff buff = unpackAuditActionResultSetToBuff(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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlAuditActionTable.java

public CFEnSyntaxAuditActionBuff lockBuff(CFEnSyntaxAuthorization Authorization,
        CFEnSyntaxAuditActionPKey PKey) {
    final String S_ProcName = "lockBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   ww w .  jav  a2s  .  co  m
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        short AuditActionId = PKey.getRequiredAuditActionId();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_lock_auditaction( ?, ?, ?, ?, ?" + ", "
                + "?" + " )";
        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.setShort(argIdx++, AuditActionId);
        try {
            resultSet = stmtLockBuffByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxAuditActionBuff buff = unpackAuditActionResultSetToBuff(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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlAuditActionTable.java

public void updateAuditAction(CFEnSyntaxAuthorization Authorization, CFEnSyntaxAuditActionBuff Buff) {
    final String S_ProcName = "updateAuditAction";
    ResultSet resultSet = null;//from  w w w .  j  ava  2  s.  co  m
    try {
        short AuditActionId = Buff.getRequiredAuditActionId();
        String Description = Buff.getRequiredDescription();
        int Revision = Buff.getRequiredRevision();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_update_auditaction( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + ", " + "?" + " )";
        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++, "AUDT");
        stmtUpdateByPKey.setShort(argIdx++, AuditActionId);
        stmtUpdateByPKey.setString(argIdx++, Description);
        stmtUpdateByPKey.setInt(argIdx++, Revision);
        try {
            resultSet = stmtUpdateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxAuditActionBuff updatedBuff = unpackAuditActionResultSetToBuff(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.setRequiredDescription(updatedBuff.getRequiredDescription());
            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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfensyntax.v2_2.CFEnSyntaxMySql.CFEnSyntaxMySqlAuditActionTable.java

public void createAuditAction(CFEnSyntaxAuthorization Authorization, CFEnSyntaxAuditActionBuff Buff) {
    final String S_ProcName = "createAuditAction";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  ww  w. j  a v  a 2s  .c  om
    ResultSet resultSet = null;
    try {
        short AuditActionId = Buff.getRequiredAuditActionId();
        String Description = Buff.getRequiredDescription();
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_create_auditaction( ?, ?, ?, ?, ?, ?" + ", "
                + "?" + ", " + "?" + " )";
        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++, "AUDT");
        stmtCreateByPKey.setShort(argIdx++, AuditActionId);
        stmtCreateByPKey.setString(argIdx++, Description);
        try {
            resultSet = stmtCreateByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxAuditActionBuff createdBuff = unpackAuditActionResultSetToBuff(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.setRequiredAuditActionId(createdBuff.getRequiredAuditActionId());
            Buff.setRequiredDescription(createdBuff.getRequiredDescription());
            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;
        }
    }
}

From source file:com.feedzai.commons.sql.abstraction.engine.impl.MySqlEngine.java

@Override
protected void addFks(DbEntity entity) throws DatabaseEngineException {
    for (DbFk fk : entity.getFks()) {
        final List<String> quotizedLocalColumns = new ArrayList<String>();
        for (String s : fk.getLocalColumns()) {
            quotizedLocalColumns.add(quotize(s, escapeCharacter()));
        }/*from   w  ww  .  j  av a2s.  c o m*/

        final List<String> quotizedForeignColumns = new ArrayList<String>();
        for (String s : fk.getForeignColumns()) {
            quotizedForeignColumns.add(quotize(s, escapeCharacter()));
        }

        final String table = quotize(entity.getName(), escapeCharacter());
        final String quotizedLocalColumnsSting = join(quotizedLocalColumns, ", ");
        final String quotizedForeignColumnsString = join(quotizedForeignColumns, ", ");

        final String alterTable = format("ALTER TABLE %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)",
                table,
                quotize(md5("FK_" + table + quotizedLocalColumnsSting + quotizedForeignColumnsString,
                        properties.getMaxIdentifierSize()), escapeCharacter()),
                quotizedLocalColumnsSting, quotize(fk.getForeignTable(), escapeCharacter()),
                quotizedForeignColumnsString);

        Statement alterTableStmt = null;
        try {
            alterTableStmt = conn.createStatement();
            logger.trace(alterTable);
            alterTableStmt.executeUpdate(alterTable);
            alterTableStmt.close();
        } catch (SQLException ex) {
            if (CONSTRAINT_NAME_ALREADY_EXISTS.contains(ex.getErrorCode())) {
                logger.debug(dev, "Foreign key for table '{}' already exists. Error code: {}.",
                        entity.getName(), ex.getErrorCode());
            } else {
                throw new DatabaseEngineException(
                        format("Could not add Foreign Key to entity %s. Error code: %d.", entity.getName(),
                                ex.getErrorCode()),
                        ex);
            }
        } finally {
            try {
                if (alterTableStmt != null) {
                    alterTableStmt.close();
                }
            } catch (Exception e) {
                logger.trace("Error closing statement.", e);
            }
        }

    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstMySql.CFAstMySqlSysClusterTable.java

public CFAstSysClusterBuff readBuffByIdIdx(CFAstAuthorization Authorization, int SingletonId) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;/*from w w  w.ja v  a2  s.co m*/
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_sysclus_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.setInt(argIdx++, SingletonId);
        try {
            resultSet = stmtReadBuffByIdIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFAstSysClusterBuff buff = unpackSysClusterResultSetToBuff(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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstMySql.CFAstMySqlSysClusterTable.java

public CFAstSysClusterBuff[] readAllBuff(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   w  ww.  j a  v  a  2  s. com
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_sysclus_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<CFAstSysClusterBuff> buffList = new LinkedList<CFAstSysClusterBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFAstSysClusterBuff buff = unpackSysClusterResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFAstSysClusterBuff[] retBuff = new CFAstSysClusterBuff[buffList.size()];
        Iterator<CFAstSysClusterBuff> 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstMySql.CFAstMySqlSysClusterTable.java

public CFAstSysClusterBuff[] readBuffByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
    final String S_ProcName = "readBuffByClusterIdx";
    ResultSet resultSet = null;//from w ww . jav  a 2 s.  co  m
    try {
        Connection cnx = schema.getCnx();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_sysclus_by_clusteridx( ?, ?, ?, ?, ?"
                + ", " + "?" + " )";
        if (stmtReadBuffByClusterIdx == null) {
            stmtReadBuffByClusterIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByClusterIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByClusterIdx.setLong(argIdx++, ClusterId);
        try {
            resultSet = stmtReadBuffByClusterIdx.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        List<CFAstSysClusterBuff> buffList = new LinkedList<CFAstSysClusterBuff>();
        while ((resultSet != null) && resultSet.next()) {
            CFAstSysClusterBuff buff = unpackSysClusterResultSetToBuff(resultSet);
            buffList.add(buff);
        }
        int idx = 0;
        CFAstSysClusterBuff[] retBuff = new CFAstSysClusterBuff[buffList.size()];
        Iterator<CFAstSysClusterBuff> 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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstMySql.CFAstMySqlSysClusterTable.java

public CFAstSysClusterBuff readBuff(CFAstAuthorization Authorization, CFAstSysClusterPKey PKey) {
    final String S_ProcName = "readBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  ww  w  . j  av a2s . c om
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        int SingletonId = PKey.getRequiredSingletonId();
        String sql = "call " + schema.getLowerDbSchemaName() + ".sp_read_sysclus( ?, ?, ?, ?, ?" + ", " + "?"
                + " )";
        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.setInt(argIdx++, SingletonId);
        try {
            resultSet = stmtReadBuffByPKey.executeQuery();
        } catch (SQLException e) {
            if (e.getErrorCode() != 1329) {
                throw e;
            }
            resultSet = null;
        }
        if ((resultSet != null) && resultSet.next()) {
            CFAstSysClusterBuff buff = unpackSysClusterResultSetToBuff(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;
        }
    }
}