Example usage for java.sql ResultSet getBoolean

List of usage examples for java.sql ResultSet getBoolean

Introduction

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

Prototype

boolean getBoolean(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstPgSql.CFAstPgSqlSysClusterTable.java

public void deleteSysClusterByIdIdx(CFAstAuthorization Authorization, int argSingletonId) {
    final String S_ProcName = "deleteSysClusterByIdIdx";
    ResultSet resultSet = null;
    try {// www .  j  a  v a2s .  c  o m
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_sysclus_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argSingletonId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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.CFAsteriskPgSql.CFAsteriskPgSqlMimeTypeTable.java

public void deleteMimeTypeByIdIdx(CFSecurityAuthorization Authorization, int argMimeTypeId) {
    final String S_ProcName = "deleteMimeTypeByIdIdx";
    ResultSet resultSet = null;
    try {// w  w  w .jav  a  2  s .c o  m
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_mimetype_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argMimeTypeId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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.CFAsteriskPgSql.CFAsteriskPgSqlServiceTypeTable.java

public void deleteServiceTypeByIdIdx(CFSecurityAuthorization Authorization, int argServiceTypeId) {
    final String S_ProcName = "deleteServiceTypeByIdIdx";
    ResultSet resultSet = null;
    try {//  www.  ja va 2s .com
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_svctype_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argServiceTypeId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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.CFAsteriskPgSql.CFAsteriskPgSqlAuditActionTable.java

public void deleteAuditActionByUDescrIdx(CFSecurityAuthorization Authorization, String argDescription) {
    final String S_ProcName = "deleteAuditActionByUDescrIdx";
    ResultSet resultSet = null;
    try {/*  ww  w  . j  a  va 2 s.co m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_auditaction_by_udescridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        if (stmtDeleteByUDescrIdx == null) {
            stmtDeleteByUDescrIdx = cnx.prepareStatement(sql);
        }
        int argIdx = 1;
        stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecUserId().toString());
        stmtDeleteByUDescrIdx.setString(argIdx++,
                (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
        stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
        stmtDeleteByUDescrIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
        stmtDeleteByUDescrIdx.setString(argIdx++, argDescription);
        resultSet = stmtDeleteByUDescrIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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.CFAccPgSql.CFAccPgSqlServiceTypeTable.java

public void deleteServiceTypeByIdIdx(CFAccAuthorization Authorization, int argServiceTypeId) {
    final String S_ProcName = "deleteServiceTypeByIdIdx";
    ResultSet resultSet = null;
    try {//from  ww  w . j a  v  a  2 s  . c  o m
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_svctype_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argServiceTypeId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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.CFAstPgSql.CFAstPgSqlServiceTypeTable.java

public void deleteServiceTypeByIdIdx(CFAstAuthorization Authorization, int argServiceTypeId) {
    final String S_ProcName = "deleteServiceTypeByIdIdx";
    ResultSet resultSet = null;
    try {/*from  w w w  . ja  v  a 2  s  .  c om*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_svctype_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argServiceTypeId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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_1.CFAstPgSql.CFAstPgSqlServiceTypeTable.java

public void deleteServiceTypeByIdIdx(CFAstAuthorization Authorization, int argServiceTypeId) {
    final String S_ProcName = "deleteServiceTypeByIdIdx";
    ResultSet resultSet = null;
    try {/*from   w  w  w .ja  v a2s  .c o m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName() + ".sp_delete_svctype_by_ididx( ?, ?, ?, ?, ?"
                + ", " + "?" + " ) as DeletedFlag";
        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.setInt(argIdx++, argServiceTypeId);
        resultSet = stmtDeleteByIdIdx.executeQuery();
        if (resultSet.next()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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:com.wso2telco.core.dbutils.AxiataDbService.java

/**
 * Check msisdn spend limit./*from   ww  w. ja v  a 2  s  .  c o  m*/
 *
 * @param msisdn the msisdn
 * @return true, if successful
 * @throws AxataDBUtilException the axata db util exception
 */
@Deprecated
public boolean checkMSISDNSpendLimit(String msisdn) throws AxataDBUtilException {
    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    boolean isExceeded = false;
    try {
        con = DbUtils.getAxiataDBConnection();

        String sql = "SELECT exists (SELECT 1 FROM " + MSISDN_SPEND_LIMIT_TABLE + " where msisdn=? LIMIT 1)";
        ps = con.prepareStatement(sql);
        ps.setString(1, msisdn);
        rs = ps.executeQuery();

        if (rs.next()) {
            isExceeded = rs.getBoolean(1);
        }
    } catch (Exception e) {
        DbUtils.handleException("Error while checking MSISDN Spend Limit. ", e);
    } finally {
        DbUtils.closeAllConnections(ps, con, rs);
    }
    return isExceeded;
}

From source file:org.bytesoft.openjtcc.supports.logger.DbTransactionLoggerImpl.java

private Map<XidImpl, TerminatorArchive> loadTerminator(Connection connection) {
    Map<XidImpl, TerminatorArchive> transactionMap = new HashMap<XidImpl, TerminatorArchive>();
    PreparedStatement stmt = null;
    ResultSet rs = null;
    try {//from   ww w  . j a  v a2  s .c o m
        StringBuilder ber = new StringBuilder();
        ber.append("select s.global_tx_id, s.to_application, s.to_endpoint");
        ber.append(", s.prepared, s.committed, s.rolledback, s.cleanup ");
        ber.append("from tcc_terminator s ");
        ber.append("left join tcc_transaction t on (");
        ber.append("        t.application = s.application ");
        ber.append("    and t.endpoint = s.endpoint ");
        ber.append("    and t.global_tx_id = s.global_tx_id ");
        ber.append(") where s.application = ? and s.endpoint = ? and t.deleted = ?");
        stmt = connection.prepareStatement(ber.toString());
        stmt.setString(1, this.instanceKey.getApplication());
        stmt.setString(2, this.instanceKey.getEndpoint());
        stmt.setBoolean(3, false);

        rs = stmt.executeQuery();
        while (rs.next()) {
            TerminatorArchive holder = new TerminatorArchive();

            String towardsApplication = rs.getString("to_application");
            String towardsEndpoint = rs.getString("to_endpoint");
            String globalTransactionId = rs.getString("global_tx_id");
            boolean prepared = rs.getBoolean("prepared");
            boolean committed = rs.getBoolean("committed");
            boolean rolledback = rs.getBoolean("rolledback");
            boolean cleanup = rs.getBoolean("cleanup");

            byte[] globalBytes = ByteUtils.stringToByteArray(globalTransactionId);
            XidImpl globalXid = this.xidFactory.createGlobalXid(globalBytes);

            holder.prepared = prepared;
            holder.committed = committed;
            holder.rolledback = rolledback;
            holder.cleanup = cleanup;

            TerminatorInfo info = new TerminatorInfo();
            info.setApplication(towardsApplication);
            info.setEndpoint(towardsEndpoint);
            info.setBranchXid(globalXid);
            RemoteTerminator terminator = this.terminatorMarshaller.unmarshallTerminator(info);
            holder.terminator = terminator;

            transactionMap.put(globalXid, holder);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        closeResultSet(rs);
        closeStatement(stmt);
    }

    return transactionMap;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskPgSql.CFAsteriskPgSqlSysClusterTable.java

public void deleteSysClusterByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSysClusterByClusterIdx";
    ResultSet resultSet = null;
    try {/*  w  w w  . ja va 2 s.c  o m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_sysclus_by_clusteridx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        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()) {
            boolean deleteFlag = resultSet.getBoolean(1);
            if (resultSet.next()) {
                throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                        "Did not expect multi-record response");
            }
        } 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;
        }
    }
}