Example usage for java.sql ResultSet last

List of usage examples for java.sql ResultSet last

Introduction

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

Prototype

boolean last() throws SQLException;

Source Link

Document

Moves the cursor to the last row in this ResultSet object.

Usage

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

public void deleteSecGroupByClusterIdx(CFCrmAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecGroupByClusterIdx";
    ResultSet resultSet = null;
    try {//from   w  w  w  .  j a v a  2 s  . c o m
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_secgrp_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.cfacc.v2_0.CFAccDb2LUW.CFAccDb2LUWISOCurrencyTable.java

public void deleteISOCurrencyByIdIdx(CFAccAuthorization Authorization, short argId) {
    final String S_ProcName = "deleteISOCurrencyByIdIdx";
    ResultSet resultSet = null;
    try {//from w w w. j  a  va2  s .  c  om
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_iso_ccy_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.setShort(argIdx++, argId);
        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.CFAstDb2LUW.CFAstDb2LUWISOCurrencyTable.java

public void deleteISOCurrencyByIdIdx(CFAstAuthorization Authorization, short argId) {
    final String S_ProcName = "deleteISOCurrencyByIdIdx";
    ResultSet resultSet = null;
    try {/*from   www .  j  av  a  2 s.  c om*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_iso_ccy_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.setShort(argIdx++, argId);
        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_4.CFAsteriskDb2LUW.CFAsteriskDb2LUWTSecGroupTable.java

public void deleteTSecGroupByTenantIdx(CFSecurityAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTSecGroupByTenantIdx";
    ResultSet resultSet = null;
    try {//  ww w .j  a  va2s .co m
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_tsecgrp_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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWISOCountryTable.java

public CFCrmISOCountryBuff readBuffByNameIdx(CFCrmAuthorization Authorization, String Name) {
    final String S_ProcName = "readBuffByNameIdx";
    ResultSet resultSet = null;
    try {/* ww  w. java  2s  . c  o  m*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_read_iso_cntry_by_nameidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
        if (stmtReadBuffByNameIdx == null) {
            stmtReadBuffByNameIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByNameIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByNameIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByNameIdx.setString(argIdx++, Name);
        resultSet = stmtReadBuffByNameIdx.executeQuery();
        if (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.cfcrm.v2_1.CFCrmDb2LUW.CFCrmDb2LUWURLProtocolTable.java

public void deleteURLProtocolByUNameIdx(CFCrmAuthorization Authorization, String argName) {
    final String S_ProcName = "deleteURLProtocolByUNameIdx";
    ResultSet resultSet = null;
    try {//from w w w.j a v a  2  s.  com
        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 nextSecAppIdGen(CFAstAuthorization Authorization, CFAstClusterPKey PKey) {
    final String S_ProcName = "nextSecAppIdGen";
    final String sqlSelectNext = "call sf_next_secappidgen(" + "?" + " )";

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

        if (stmtSelectNextSecAppIdGen == null) {
            stmtSelectNextSecAppIdGen = cnx.prepareStatement(sqlSelectNext);
        }
        int nextId;
        int argIdx = 1;
        stmtSelectNextSecAppIdGen.setLong(argIdx++, Id);
        rsSelect = stmtSelectNextSecAppIdGen.executeQuery();
        if (rsSelect.next()) {
            nextId = rsSelect.getInt(1);
            if (rsSelect.wasNull()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "NextSecAppIdGen 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_secappidgen(), 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.cfensyntax.v2_2.CFEnSyntaxMSSql.CFEnSyntaxMSSqlServiceTypeTable.java

public CFEnSyntaxServiceTypeBuff readBuffByUDescrIdx(CFEnSyntaxAuthorization Authorization,
        String Description) {//from www. j  a va  2 s.  co m
    final String S_ProcName = "readBuffByUDescrIdx";
    ResultSet resultSet = null;
    try {
        Connection cnx = schema.getCnx();
        String sql = "{ call sp_read_svctype_by_udescridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) }";
        if (stmtReadBuffByUDescrIdx == null) {
            stmtReadBuffByUDescrIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtReadBuffByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtReadBuffByUDescrIdx.setLong(argIdx++,
                (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtReadBuffByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtReadBuffByUDescrIdx.setString(argIdx++, Description);
        resultSet = stmtReadBuffByUDescrIdx.executeQuery();
        if ((resultSet != null) && resultSet.next()) {
            CFEnSyntaxServiceTypeBuff buff = unpackServiceTypeResultSetToBuff(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.CFAccDb2LUWTldTable.java

public void deleteTldByTenantIdx(CFAccAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTldByTenantIdx";
    ResultSet resultSet = null;
    try {/*w w w  .  ja v  a  2  s. c o  m*/
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_tlddef_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_0.CFAstDb2LUW.CFAstDb2LUWTldTable.java

public void deleteTldByTenantIdx(CFAstAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTldByTenantIdx";
    ResultSet resultSet = null;
    try {//w  w w.  j av a2 s.co m
        Connection cnx = schema.getCnx();
        final String sql = "CALL sp_delete_tlddef_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;
        }
    }
}