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.CFCrmMSSqlSecDeviceTable.java

public CFCrmSecDeviceBuff readBuffByIdIdx(CFCrmAuthorization Authorization, UUID SecUserId, String DevName) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;
    try {//from   ww w.  j av  a 2s . co  m
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_secdev_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++, SecUserId.toString());
        stmtReadBuffByIdIdx.setString(argIdx++, DevName);
        resultSet = stmtReadBuffByIdIdx.executeQuery();
        if ((resultSet != null) && resultSet.next()) {
            CFCrmSecDeviceBuff buff = unpackSecDeviceResultSetToBuff(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.cfasterisk.v2_0.CFAstOracle.CFAstOracleTenantTable.java

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

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

        if (stmtSelectNextTLDIdGen == null) {
            stmtSelectNextTLDIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        long nextId;
        int argIdx = 1;
        stmtSelectNextTLDIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextTLDIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getLong(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextTLDIdGen 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_tldidgen(), 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 nextTldIdGen(CFAstAuthorization Authorization, CFAstTenantPKey PKey) {
    final String S_ProcName = "nextTldIdGen";
    String sqlSelectNext = "SELECT " + schema.getLowerDbSchemaName() + ".nxt_tldidgen(" + "?"
            + " ) as NextTldIdGen from dual";

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

        if (stmtSelectNextTldIdGen == null) {
            stmtSelectNextTldIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        long nextId;
        int argIdx = 1;
        stmtSelectNextTldIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextTldIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getLong(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextTldIdGen 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_tldidgen(), 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_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWURLProtocolTable.java

public void deleteURLProtocolByUNameIdx(CFSecurityAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteURLProtocolByUNameIdx";
    ResultSet resultSet = null;
    try {//from ww  w .  j  a v a2  s.  c  o m
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_urlproto_by_unameidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByUNameIdx == null) {
            stmtDeleteByUNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByUNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByUNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByUNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByUNameIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByUNameIdx.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.CFAstDb2LUW.CFAstDb2LUWClusterTable.java

public int nextSecFormIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecFormIdGen";
    final String sqlSelectNext = "call sf_next_secformidgen(" + "?" + " )";

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

        if (stmtSelectNextSecFormIdGen == null) {
            stmtSelectNextSecFormIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        int nextId;
        int argIdx = 1;
        stmtSelectNextSecFormIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextSecFormIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getInt(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextSecFormIdGen 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 sf_next_secformidgen(), 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_4.CFAsteriskSybase.CFAsteriskSybaseISOCountryTable.java

public CFSecurityISOCountryBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, short Id) {
    final String S_ProcName = "readBuffByIdIdx";
    ResultSet resultSet = null;
    try {//  ww w.  j av  a  2s  .  c om
        Connection cnx = schema.getCnx();
        String sql = "exec 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.next()) {
            CFSecurityISOCountryBuff 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.cfasterisk.v2_4.CFAsteriskOracle.CFAsteriskOracleTenantTable.java

public long nextDomainIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey 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");
    }//  ww  w  . j  a v a 2s.  c  o 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.CFAstDb2LUW.CFAstDb2LUWClusterTable.java

public long nextServiceIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextServiceIdGen";
    final String sqlSelectNext = "call sf_next_serviceidgen(" + "?" + " )";

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

        if (stmtSelectNextServiceIdGen == null) {
            stmtSelectNextServiceIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        long nextId;
        int argIdx = 1;
        stmtSelectNextServiceIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextServiceIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getLong(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextServiceIdGen 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 sf_next_serviceidgen(), 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_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWSecAppTable.java

public void deleteSecAppByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecAppByClusterIdx";
    ResultSet resultSet = null;
    try {//from  w  ww.  jav a 2 s  .com
        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;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWISOCurrencyTable.java

public void deleteISOCurrencyByCcyNmIdx(CFCrmAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteISOCurrencyByCcyNmIdx";
    ResultSet resultSet = null;
    try {/*from  w w  w. ja v  a2  s .c o m*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_iso_ccy_by_ccynmidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtDeleteByCcyNmIdx == null) {
            stmtDeleteByCcyNmIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCcyNmIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByCcyNmIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByCcyNmIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByCcyNmIdx.setString(argIdx++, argName);
        resultSet = stmtDeleteByCcyNmIdx.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;
        }
    }
}