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:com.surevine.alfresco.audit.integration.AuditRowMapper.java

public Object mapRow(ResultSet rs, int rowCount) throws SQLException {

    Auditable audited = new AuditItem();
    audited.setAction(rs.getString("action"));
    audited.setSource(rs.getString("source"));
    audited.setVersion(rs.getString("version"));
    audited.setRemoteAddress(rs.getString("remote_addr"));
    audited.setUser(rs.getString("username"));
    audited.setDetails(rs.getString("details"));
    audited.setSuccess(rs.getBoolean("success"));
    audited.setUrl(rs.getString("url"));
    audited.setDate(new Date(rs.getTimestamp("tstamp").getTime()));
    audited.setSite(rs.getString("site"));
    audited.setVersion(rs.getString("version"));
    audited.setSecLabel(rs.getString("secLabel"));
    audited.setTags(rs.getString("tags"));
    audited.setNodeRef(rs.getString("node_ref"));

    return audited;
}

From source file:com.github.dbourdette.glass.log.execution.jdbc.JdbcJobExecutions.java

private Page<JobExecution> getLogs(String sqlBase, SqlParameterSource params, Query query) {
    String sql = query.applySqlLimit("select * " + sqlBase + " order by startDate desc");

    List<JobExecution> executions = jdbcTemplate.query(sql, params, new RowMapper<JobExecution>() {
        @Override//from  w ww  .ja va2s.c  om
        public JobExecution mapRow(ResultSet rs, int rowNum) throws SQLException {
            JobExecution execution = new JobExecution();

            execution.setId(rs.getLong("id"));
            execution.setStartDate(rs.getTimestamp("startDate"));
            execution.setEndDate(rs.getTimestamp("endDate"));
            execution.setEnded(rs.getBoolean("ended"));
            execution.setJobGroup(rs.getString("jobGroup"));
            execution.setJobName(rs.getString("jobName"));
            execution.setTriggerGroup(rs.getString("triggerGroup"));
            execution.setTriggerName(rs.getString("triggerName"));
            execution.setJobClass(rs.getString("jobClass"));
            execution.setDataMap(rs.getString("dataMap"));
            execution.setResult(JobExecutionResult.valueOf(rs.getString("result")));

            return execution;
        }
    });

    String countSql = "select count(*) " + sqlBase;

    Page<JobExecution> page = Page.fromQuery(query);

    page.setItems(executions);
    page.setTotalCount(jdbcTemplate.queryForInt(countSql, params));

    return page;
}

From source file:com.nabla.wapp.server.json.SqlColumn.java

public void write(final ResultSet rs, int column, final JSONObject record) throws SQLException {
    switch (type) {
    case Types.BIGINT:
    case Types.INTEGER:
    case Types.SMALLINT:
    case Types.TINYINT:
        record.put(label, rs.getInt(column));
        break;//from w w w.  j a  v  a  2  s  .c  o m
    case Types.BOOLEAN:
    case Types.BIT:
        record.put(label, rs.getBoolean(column));
        break;
    case Types.DATE:
        final Date dt = rs.getDate(column);
        if (rs.wasNull())
            record.put(label, null);
        else
            record.put(label, new JSonDate(dt));
        return;
    case Types.TIMESTAMP:
        final Timestamp tm = rs.getTimestamp(column);
        if (rs.wasNull())
            record.put(label, null);
        else
            record.put(label, timeStampFormat.format(tm));
        return;
    case Types.DOUBLE:
        record.put(label, rs.getDouble(column));
        break;
    case Types.FLOAT:
        record.put(label, rs.getFloat(column));
        break;
    case Types.NULL:
        record.put(label, null);
        return;
    default:
        record.put(label, rs.getString(column));
        break;
    }
    if (rs.wasNull())
        record.put(label, null);
}

From source file:data.DefaultExchanger.java

protected void putBoolean(JsonGenerator generator, String fieldName, ResultSet rs, short index)
        throws SQLException, IOException {
    generator.writeFieldName(fieldName);
    generator.writeBoolean(rs.getBoolean(index));
}

From source file:com.flexive.core.storage.PostgreSQL.PostgreSQLSequencerStorage.java

private CustomSequencer loadCustomSequencer(Statement nonTxStatement, String name)
        throws SQLException, FxCreateException {
    // use non-transactional connection since the relation may have been deleted by another
    // thread, which would lead to a rollback on the main connection
    ResultSet rsi = null;
    try {/* w w w  . j a v  a 2s  .  co m*/
        rsi = nonTxStatement.executeQuery(SQL_GET_INFO + PG_SEQ_PREFIX + name);
        if (rsi.next()) {
            return new CustomSequencer(name, rsi.getBoolean(1), rsi.getLong(2));
        } else {
            throw new FxCreateException("ex.sequencer.notFound", name);
        }
    } catch (SQLException e) {
        throw new FxCreateException("ex.sequencer.notFound", name);
    } finally {
        if (rsi != null) {
            rsi.close();
        }
    }
}

From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java

/**
 * Check the scope is backChannel allowed
 *
 * @param scope scope value/*from ww  w  . j a v a2  s. c o m*/
 * @return allowed or not allowed
 * @throws ConfigurationException on errors
 */
public static boolean isBackChannelAllowedScope(String scope)
        throws ConfigurationException, CommonAuthenticatorException {

    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    boolean isBackChannelAllowed = false;

    String[] scopeValues = scope.split("\\s+|\\+");
    StringBuilder params = new StringBuilder("?");
    for (int i = 1; i < scopeValues.length; i++) {
        params.append(",?");
    }

    String sql = "SELECT is_backchannel_allowed FROM scope_parameter WHERE scope in (" + params + ") ;";

    if (log.isDebugEnabled()) {
        log.debug("Executing the query to check the scope is backChannel allowed: " + sql);
    }

    try {
        connection = getConnectDBConnection();
        preparedStatement = connection.prepareStatement(sql);
        for (int i = 0; i < scopeValues.length; i++) {
            preparedStatement.setString(i + 1, scopeValues[i]);
        }

        resultSet = preparedStatement.executeQuery();

        while (resultSet.next()) {
            isBackChannelAllowed = resultSet.getBoolean("is_backchannel_allowed");

            if (!isBackChannelAllowed) {
                isBackChannelAllowed = false;
            }
        }

    } catch (SQLException e) {
        handleException("Error occurred while checking the scope is back channel allowed - " + scope, e);
    } catch (NamingException e) {
        throw new ConfigurationException("DataSource could not be found in mobile-connect.xml");
    } finally {
        closeAllConnections(preparedStatement, connection, resultSet);
    }
    return isBackChannelAllowed;
}

From source file:com.abcd.employeemaven.dao.impl.DepartmentDaoImpl.java

public Department mapData(ResultSet rs) throws SQLException {

    Department department = new Department();
    department.setId(rs.getInt("department_id"));
    department.setDepartmentCode(rs.getString("department_code"));
    department.setDepartmentDescription(rs.getString("department_description"));
    department.setAddedDate(rs.getDate("added_date"));
    department.setModifiedDate(rs.getDate("modified_date"));
    department.setStatus(rs.getBoolean("status"));

    return department;

}

From source file:biz.wolschon.finance.jgnucash.mysql.impl.AccountRowMapper.java

/**
 * @param aResultSet the result-set whos current result to map
 * @param aRowNumber the current row-number in the result-set
 * @return the result mapped to a bean/* w  w w . j  a  v  a 2 s. co m*/
 * @throws SQLException on problems with the database
 * @see org.springframework.jdbc.core.simple.ParameterizedRowMapper#mapRow(java.sql.ResultSet, int)
 */
@Override
public GnucashDBAccount mapRow(final ResultSet aResultSet, final int aRowNumber) throws SQLException {
    GnucashDBAccount retval = new GnucashDBAccount(myGnucashFile, aResultSet.getString("guid"),
            aResultSet.getString("parent_guid"), aResultSet.getString("name"),
            aResultSet.getString(COLUMNACCOUNTTYPE), aResultSet.getString("code"),
            aResultSet.getString("commodity_guid"), aResultSet.getInt("commodity_scu"),
            aResultSet.getBoolean("non_std_scu"));
    if (aResultSet.getString("parent_guid") != null) {
        retval.setParentAccountId(aResultSet.getString("guid"));
    }
    if (aResultSet.getString("description") != null) {
        retval.setDescription(aResultSet.getString("description"));
    }
    return retval;
}

From source file:com.alfaariss.oa.engine.attribute.release.jdbc.JDBCPolicy.java

/**
 * Initializes the policy.//from   w w w.j  ava  2 s . c  om
 * 
 * @param dataSource the JDBC datasource
 * @param resultSet A resultset containing a row with policy information
 * @param attributeTable attribute table name
 * @throws AttributeException if initialization fails
 */
public JDBCPolicy(DataSource dataSource, ResultSet resultSet, String attributeTable) throws AttributeException {
    try {
        _logger = LogFactory.getLog(JDBCPolicy.class);

        _sID = resultSet.getString(COLUMN_POLICY_ID);
        _sFriendlyName = resultSet.getString(COLUMN_POLICY_FRIENDLYNAME);
        _bEnabled = resultSet.getBoolean(COLUMN_POLICY_ENABLED);

        _vAttributeNames = readAttributes(dataSource, attributeTable);
    } catch (Exception e) {
        _logger.fatal("Internal error during initialization", e);
        throw new AttributeException(SystemErrors.ERROR_INTERNAL);
    }
}

From source file:henu.dao.impl.CaclDaoImpl.java

@Override
public Cacl getCacl(String cid) {
    String sql = "select * from cacl where cid=" + cid;

    ResultSet rs = SqlDB.executeQuery(sql);
    Cacl cacl = new Cacl();

    try {//from   w  w  w.j  av a2 s.  c  o  m
        cacl.setTid(rs.getLong("cid"));
        cacl.setName(rs.getString("cname"));
        cacl.setStructure(rs.getString("structure"));
        cacl.setAuthor(rs.getInt("author"));
        cacl.setType(rs.getBoolean("ctype"));
        cacl.setPostime(rs.getTimestamp("postime").toString());
        cacl.setEndtime(rs.getString("endtime"));
        cacl.setUsers(getCaclUserList(cid));

    } catch (SQLException ex) {
        Logger.getLogger(CaclDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
    }

    SqlDB.close();

    return cacl;
}