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:dk.netarkivet.harvester.datamodel.HarvestDefinitionDBDAO.java

/**
 * Read the stored harvest definition for the given ID.
 *
 * @see HarvestDefinitionDAO#read(Long)//from  ww  w  .  j a  v  a2  s. c  om
 * @param c
 *            The used database connection
 * @param harvestDefinitionID
 *            An ID number for a harvest definition
 * @return A harvest definition that has been read from persistent storage.
 * @throws UnknownID
 *             if no entry with that ID exists in the database
 * @throws IOFailure
 *             If DB-failure occurs?
 */
private HarvestDefinition read(Connection c, Long harvestDefinitionID) throws UnknownID, IOFailure {

    if (!exists(c, harvestDefinitionID)) {
        String message = "Unknown harvest definition " + harvestDefinitionID;
        log.debug(message);
        throw new UnknownID(message);
    }
    log.debug("Reading harvestdefinition w/ id " + harvestDefinitionID);
    PreparedStatement s = null;
    try {
        s = c.prepareStatement(
                "SELECT name, comments, numevents, submitted, " + "previoushd, maxobjects, maxbytes, "
                        + "maxjobrunningtime, isindexready, isactive, edition, audience "
                        + "FROM harvestdefinitions, fullharvests " + "WHERE harvestdefinitions.harvest_id = ?"
                        + "  AND harvestdefinitions.harvest_id " + " = fullharvests.harvest_id");
        s.setLong(1, harvestDefinitionID);
        ResultSet res = s.executeQuery();
        if (res.next()) {
            // Found full harvest
            log.debug("fullharvest found w/id " + harvestDefinitionID);
            final String name = res.getString(1);
            final String comments = res.getString(2);
            final int numEvents = res.getInt(3);
            final Date submissionDate = new Date(res.getTimestamp(4).getTime());
            final long maxObjects = res.getLong(6);
            final long maxBytes = res.getLong(7);
            final long maxJobRunningtime = res.getLong(8);
            final boolean isIndexReady = res.getBoolean(9);
            FullHarvest fh;
            final long prevhd = res.getLong(5);
            if (!res.wasNull()) {
                fh = new FullHarvest(name, comments, prevhd, maxObjects, maxBytes, maxJobRunningtime,
                        isIndexReady);
            } else {
                fh = new FullHarvest(name, comments, null, maxObjects, maxBytes, maxJobRunningtime,
                        isIndexReady);
            }
            fh.setSubmissionDate(submissionDate);
            fh.setNumEvents(numEvents);
            fh.setActive(res.getBoolean(10));
            fh.setOid(harvestDefinitionID);
            fh.setEdition(res.getLong(11));
            fh.setAudience(res.getString(12));

            readExtendedFieldValues(fh);

            // We found a FullHarvest object, just return it.
            log.debug("Returned FullHarvest object w/ id " + harvestDefinitionID);
            return fh;
        }
        s.close();
        // No full harvest with that ID, try selective harvest
        s = c.prepareStatement("SELECT harvestdefinitions.name," + "       harvestdefinitions.comments,"
                + "       harvestdefinitions.numevents," + "       harvestdefinitions.submitted,"
                + "       harvestdefinitions.isactive," + "       harvestdefinitions.edition,"
                + "       harvestdefinitions.audience," + "       schedules.name,"
                + "       partialharvests.nextdate, " + "       harvestdefinitions.channel_id "
                + "FROM harvestdefinitions, partialharvests, schedules"
                + " WHERE harvestdefinitions.harvest_id = ?" + "   AND harvestdefinitions.harvest_id "
                + "= partialharvests.harvest_id" + "   AND schedules.schedule_id "
                + "= partialharvests.schedule_id");
        s.setLong(1, harvestDefinitionID);
        res = s.executeQuery();
        boolean foundPartialHarvest = res.next();
        if (foundPartialHarvest) {
            log.debug("Partialharvest found w/ id " + harvestDefinitionID);
            // Have to get configs before creating object, so storing data
            // here.
            final String name = res.getString(1);
            final String comments = res.getString(2);
            final int numEvents = res.getInt(3);
            final Date submissionDate = new Date(res.getTimestamp(4).getTime());
            final boolean active = res.getBoolean(5);
            final long edition = res.getLong(6);
            final String audience = res.getString(7);
            final String scheduleName = res.getString(8);
            final Date nextDate = DBUtils.getDateMaybeNull(res, 9);
            final Long channelId = DBUtils.getLongMaybeNull(res, 10);
            s.close();
            // Found partial harvest -- have to find configurations.
            // To avoid holding on to the readlock while getting domains,
            // we grab the strings first, then look up domains and configs.
            final DomainDAO domainDao = DomainDAO.getInstance();
            List<SparseDomainConfiguration> configs = new ArrayList<SparseDomainConfiguration>();
            s = c.prepareStatement("SELECT domains.name, configurations.name "
                    + "FROM domains, configurations, harvest_configs " + "WHERE harvest_id = ?"
                    + "  AND configurations.config_id " + "= harvest_configs.config_id"
                    + "  AND configurations.domain_id = domains.domain_id");
            s.setLong(1, harvestDefinitionID);
            res = s.executeQuery();
            while (res.next()) {
                configs.add(new SparseDomainConfiguration(res.getString(1), res.getString(2)));
            }
            s.close();
            List<DomainConfiguration> configurations = new ArrayList<DomainConfiguration>();
            for (SparseDomainConfiguration domainConfig : configs) {
                configurations.add(domainDao.getDomainConfiguration(domainConfig.getDomainName(),
                        domainConfig.getConfigurationName()));
            }

            Schedule schedule = ScheduleDAO.getInstance().read(scheduleName);

            PartialHarvest ph = new PartialHarvest(configurations, schedule, name, comments, audience);

            ph.setNumEvents(numEvents);
            ph.setSubmissionDate(submissionDate);
            ph.setActive(active);
            ph.setEdition(edition);
            ph.setNextDate(nextDate);
            ph.setOid(harvestDefinitionID);
            if (channelId != null) {
                ph.setChannelId(channelId);
            }

            readExtendedFieldValues(ph);

            return ph;
        } else {
            throw new IllegalState(
                    "No entries in fullharvests or " + "partialharvests found for id " + harvestDefinitionID);
        }
    } catch (SQLException e) {
        throw new IOFailure("SQL Error while reading harvest definition " + harvestDefinitionID + "\n"
                + ExceptionUtils.getSQLExceptionCause(e), e);
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlTSecGroupTable.java

public void deleteTSecGroupByTenantIdx(CFAccAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTSecGroupByTenantIdx";
    ResultSet resultSet = null;
    try {//from  w w  w  .  j av  a 2s .com
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_tsecgrp_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        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()) {
            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.CFAstPgSqlTSecGroupTable.java

public void deleteTSecGroupByTenantIdx(CFAstAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTSecGroupByTenantIdx";
    ResultSet resultSet = null;
    try {/* ww w . ja v a  2s  . co m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_tsecgrp_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        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()) {
            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.CFAstPgSqlTSecGroupTable.java

public void deleteTSecGroupByTenantIdx(CFAstAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "deleteTSecGroupByTenantIdx";
    ResultSet resultSet = null;
    try {/*from  ww w .  ja v  a2  s . co m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_tsecgrp_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag";
        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()) {
            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.CFAsteriskPgSqlSecGroupTable.java

public void deleteSecGroupByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecGroupByClusterIdx";
    ResultSet resultSet = null;
    try {//w  ww . jav a  2  s  .c  o  m
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_secgrp_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;
        }
    }
}

From source file:com.nextep.designer.sqlgen.db2.impl.DB2Capturer.java

@Override
public Collection<ISequence> getSequences(ICaptureContext context, IProgressMonitor monitor) {
    monitor.subTask("Retrieving sequences...");
    Collection<ISequence> sequences = new ArrayList<ISequence>();

    Statement stmt = null;//from   w  w w.ja va2  s  .  c om
    ResultSet rset = null;
    try {
        stmt = ((Connection) context.getConnectionObject()).createStatement();

        rset = stmt.executeQuery("SELECT seqname, remarks, start, minvalue, maxvalue, increment, cache, " //$NON-NLS-1$
                + "DECODE(cycle,'Y',1,0) is_cycle, DECODE(order,'Y',1,0) is_order " //$NON-NLS-1$
                + "FROM syscat.sequences WHERE seqschema = '" + context.getSchema() + "' AND seqtype <> 'A'"); //$NON-NLS-1$ //$NON-NLS-2$
        CaptureHelper.updateMonitor(monitor, getCounter(), 1, 1);

        while (rset.next()) {
            final String seqName = rset.getString("seqname"); //$NON-NLS-1$
            final String seqDesc = rset.getString("remarks"); //$NON-NLS-1$
            final BigDecimal seqStart = rset.getBigDecimal("start"); //$NON-NLS-1$
            final BigDecimal seqMinvalue = rset.getBigDecimal("minvalue"); //$NON-NLS-1$
            final BigDecimal seqMaxvalue = rset.getBigDecimal("maxvalue"); //$NON-NLS-1$

            /*
             * FIXME [BGA]: The increment value in DB2 dictionary tables is stored as a
             * DECIMAL(31,0), like the start, min and max values of the sequences. We should
             * check if it poses a problem with the mapping with a "Long" in the neXtep model
             * and a "BIGINT" in the neXtep repository.
             */
            final long seqIncrement = rset.getLong("increment"); //$NON-NLS-1$
            final int seqCacheSize = rset.getInt("cache"); //$NON-NLS-1$
            final boolean isCycle = rset.getBoolean("is_cycle"); //$NON-NLS-1$
            final boolean isOrder = rset.getBoolean("is_order"); //$NON-NLS-1$

            if (seqName != null && !"".equals(seqName.trim())) { //$NON-NLS-1$
                if (LOGGER.isDebugEnabled()) {
                    String logPrefix = "[" + seqName + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                    LOGGER.debug("= " + logPrefix + " Sequence Metadata ="); //$NON-NLS-1$ //$NON-NLS-2$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.START] " + seqStart); //$NON-NLS-1$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.MINVALUE] " + seqMinvalue); //$NON-NLS-1$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.MAXVALUE] " + seqMaxvalue); //$NON-NLS-1$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.INCREMENT] " + seqIncrement); //$NON-NLS-1$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.CACHE] " + seqCacheSize); //$NON-NLS-1$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.CYCLE] " //$NON-NLS-1$
                            + (isCycle ? "Y" : "N")); //$NON-NLS-1$ //$NON-NLS-2$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.ORDER] " //$NON-NLS-1$
                            + (isOrder ? "Y" : "N")); //$NON-NLS-1$ //$NON-NLS-2$
                    LOGGER.debug(logPrefix + "[SYSCAT.SEQUENCES.REMARKS] " + seqDesc); //$NON-NLS-1$
                }

                if (seqStart != null && seqMinvalue != null && seqMaxvalue != null) {
                    IVersionable<ISequence> v = VersionableFactory.createVersionable(ISequence.class);

                    ISequence sequence = v.getVersionnedObject().getModel();
                    sequence.setName(seqName);
                    sequence.setDescription(seqDesc);
                    sequence.setStart(seqStart);
                    sequence.setMinValue(seqMinvalue);
                    sequence.setMaxValue(seqMaxvalue);
                    sequence.setIncrement(seqIncrement);
                    sequence.setCached(seqCacheSize > 0);
                    sequence.setCacheSize(seqCacheSize);
                    sequence.setCycle(isCycle);
                    sequence.setOrdered(isOrder);

                    sequences.add(sequence);
                    CaptureHelper.updateMonitor(monitor, getCounter(), 5, 1);
                } else {
                    LOGGER.warn("Sequence [" + seqName + "] has been ignored during import because one of its "
                            + "start, minimum or maximum values could not be fetched " + "from database");
                }
            }
        }
    } catch (SQLException sqle) {
        LOGGER.error("Unable to fetch synonyms from DB2 server: " + sqle.getMessage(), sqle);
    } finally {
        CaptureHelper.safeClose(rset, stmt);
    }

    return sequences;
}

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

public void deleteSecAppByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecAppByClusterIdx";
    ResultSet resultSet = null;
    try {//  w  ww . j  a v a  2 s . c om
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerDbSchemaName()
                + ".sp_delete_secapp_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;
        }
    }
}

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

public boolean isSystemUser(CFAstAuthorization Authorization) {
    if (!inTransaction) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), "isSystemUser",
                "Not in a transaction");
    }//www . j av  a 2 s . c o  m
    ResultSet resultSet = null;
    try {
        String sql = "SELECT " + lowerSchemaDbName + ".sp_is_system_user( ? ) as IsSystemUser";
        if (stmtSelectIsSystemUser == null) {
            stmtSelectIsSystemUser = cnx.prepareStatement(sql);
        }
        stmtSelectIsSystemUser.setString(1, Authorization.getSecUserId().toString());
        resultSet = stmtSelectIsSystemUser.executeQuery();
        boolean resultFlag;
        if (resultSet.next()) {
            resultFlag = resultSet.getBoolean(1);
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), "isSystemUser",
                    "Query of sp_is_system_user() did not return a result row");
        }
        resultSet.close();
        return (resultFlag);
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "isSystemUser", e);
    } finally {
        if (resultSet != null) {
            try {
                resultSet.close();
            } catch (SQLException e) {
            }
            resultSet = null;
        }
    }
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql.CFAccPgSqlSecGroupTable.java

public void deleteSecGroupByClusterIdx(CFAccAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecGroupByClusterIdx";
    ResultSet resultSet = null;
    try {//www.  j  av a  2  s.  c  o m
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_secgrp_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;
        }
    }
}

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

public void deleteSecGroupByClusterIdx(CFAstAuthorization Authorization, long argClusterId) {
    final String S_ProcName = "deleteSecGroupByClusterIdx";
    ResultSet resultSet = null;
    try {/*from  w w  w  .ja  va 2s . c o m*/
        Connection cnx = schema.getCnx();
        String sql = "SELECT " + schema.getLowerSchemaDbName()
                + ".sp_delete_secgrp_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;
        }
    }
}