Example usage for java.sql ResultSet getRow

List of usage examples for java.sql ResultSet getRow

Introduction

In this page you can find the example usage for java.sql ResultSet getRow.

Prototype

int getRow() throws SQLException;

Source Link

Document

Retrieves the current row number.

Usage

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmMSSql.CFCrmMSSqlISOCountryTable.java

public CFCrmISOCountryBuff readBuffByIdIdx(CFCrmAuthorization Authorization, short Id) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;
    try {//from  ww  w  .  j  a  va  2  s  .com
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_iso_cntry_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.setShort(argIdx++, Id);
        resultSet = stmtReadBuffByIdIdx.executeQuery();
        if ((resultSet != null) && resultSet.next()) {
            CFCrmISOCountryBuff buff = unpackISOCountryResultSetToBuff(resultSet);
            if (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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWTagTable.java

public void deleteTagByTenantIdx(CFAccAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTagByTenantIdx";
    ResultSet resultSet = null;
    try {/*from   ww w  .  ja  v  a  2 s  . co m*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_tag_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByTenantIdx == null) {
            stmtDeleteByTenantIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByTenantIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByTenantIdx.setLong(argIdx++, argTenantId);
        resultSet = stmtDeleteByTenantIdx.executeQuery();
        if (resultSet.next()) {
            int deleteFlag = resultSet.getInt(1);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } 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_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWISOCurrencyTable.java

public void deleteISOCurrencyByCcyCdIdx(CFSecurityAuthorization Authorization, String argISOCode) {
    final String S_ProcName = "deleteISOCurrencyByCcyCdIdx";
    ResultSet resultSet = null;
    try {//from  w  ww . j  ava 2  s  . c  om
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_iso_ccy_by_ccycdidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByCcyCdIdx == null) {
            stmtDeleteByCcyCdIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCcyCdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCcyCdIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCcyCdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByCcyCdIdx.setString(argIdx++, argISOCode);
        resultSet = stmtDeleteByCcyCdIdx.executeQuery();
        if (resultSet.next()) {
            int deleteFlag = resultSet.getInt(1);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } 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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWSecGroupTable.java

public void deleteSecGroupByIdIdx(CFCrmAuthorization Authorization, long argClusterId, int argSecGroupId) {
    final String S_ProcName = "deleteSecGroupByIdIdx";
    ResultSet resultSet = null;
    try {//from   w ww.ja va  2  s  .c  o m
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_secgrp_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.setLong(argIdx++, argClusterId);
        stmtDeleteByIdIdx.setInt(argIdx++, argSecGroupId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            int deleteFlag = resultSet.getInt(1);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } 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_0.CFAstOracle.CFAstOracleTenantTable.java

public long nextDomainIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextDomainIdGen";
    String sqlSelectNext = "SELECT " + schema.getLowerSchemaDbName() + ".nxt_domainidgen(" + "?"
            + " ) as NextDomainIdGen from dual";

    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from ww  w. j  a v a 2s  .  co m*/
    ResultSet rsSelect = null;
    try {
        Connection cnx = schema.getCnx();
        long Id = PKey.getRequiredId();

        if (stmtSelectNextDomainIdGen == null) {
            stmtSelectNextDomainIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        long nextId;
        int argIdx = 1;
        stmtSelectNextDomainIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextDomainIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getLong(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextDomainIdGen cannot be null!");
            }
            if (rsSelect.next()) {
                rsSelect.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 result row to be returned by nxt_domainidgen(), not 0");
        }
        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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstPgSql.CFAstPgSqlClusterTable.java

public int nextSecGroupIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecGroupIdGen";
    String sqlSelectNext = "SELECT " + schema.getLowerSchemaDbName() + ".sp_next_secgroupidgen(" + "?"
            + " ) as NextSecGroupIdGen";

    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   w  ww. ja v a  2 s . co m
    ResultSet rsSelect = null;
    try {
        Connection cnx = schema.getCnx();
        long Id = PKey.getRequiredId();

        if (stmtSelectNextSecGroupIdGen == null) {
            stmtSelectNextSecGroupIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        int nextId;
        int argIdx = 1;
        stmtSelectNextSecGroupIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextSecGroupIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getInt(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextSecGroupIdGen cannot be null!");
            }
            if (rsSelect.next()) {
                rsSelect.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 result row to be returned by sp_next_secgroupidgen(), not 0");
        }
        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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_1.CFAstOracle.CFAstOracleTenantTable.java

public long nextDomainIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextDomainIdGen";
    String sqlSelectNext = "SELECT " + schema.getLowerDbSchemaName() + ".nxt_domainidgen(" + "?"
            + " ) as NextDomainIdGen from dual";

    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  ww  w  .  j  a  v  a 2  s.c  om*/
    ResultSet rsSelect = null;
    try {
        Connection cnx = schema.getCnx();
        long Id = PKey.getRequiredId();

        if (stmtSelectNextDomainIdGen == null) {
            stmtSelectNextDomainIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        long nextId;
        int argIdx = 1;
        stmtSelectNextDomainIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextDomainIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getLong(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextDomainIdGen cannot be null!");
            }
            if (rsSelect.next()) {
                rsSelect.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record select response, " + rsSelect.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 result row to be returned by nxt_domainidgen(), not 0");
        }
        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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWISOCountryTable.java

public CFAccISOCountryBuff readBuff(CFAccAuthorization Authorization, CFAccISOCountryPKey PKey) {
    final String S_ProcName = "readBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*  w  ww .j a  v  a 2  s.  c o  m*/
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        short Id = PKey.getRequiredId();
        final String sql = "CALL sp_read_iso_cntry( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        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++, Id);
        resultSet = stmtReadBuffByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccISOCountryBuff buff = unpackISOCountryResultSetToBuff(resultSet);
            if (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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWISOCountryTable.java

public CFAccISOCountryBuff lockBuff(CFAccAuthorization Authorization, CFAccISOCountryPKey PKey) {
    final String S_ProcName = "lockBuff";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from  w  ww  .  ja v  a 2 s. c  o m
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        short Id = PKey.getRequiredId();
        final String sql = "CALL sp_lock_iso_cntry( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        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++, Id);
        resultSet = stmtLockBuffByPKey.executeQuery();
        if (resultSet.next()) {
            CFAccISOCountryBuff buff = unpackISOCountryResultSetToBuff(resultSet);
            if (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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWSecAppTable.java

public void deleteSecAppByClusterIdx(CFAccAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecAppByClusterIdx";
    ResultSet resultSet = null;
    try {/*from w ww .  j av a  2 s . co m*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_secapp_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByClusterIdx == null) {
            stmtDeleteByClusterIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByClusterIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByClusterIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByClusterIdx.setLong(argIdx++, argClusterId);
        resultSet = stmtDeleteByClusterIdx.executeQuery();
        if (resultSet.next()) {
            int deleteFlag = resultSet.getInt(1);
            if (resultSet.next()) {
                resultSet.last();
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Expected 1 record result set to be returned by delete, not 0 rows");
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}