Example usage for java.sql ResultSet getInt

List of usage examples for java.sql ResultSet getInt

Introduction

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

Prototype

int getInt(String columnLabel) throws SQLException;

Source Link

Document

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

Usage

From source file:de.whs.poodle.WorksheetAutoUnlockScheduler.java

@Scheduled(fixedRate = RATE_MS)
public void unlockWorksheets() {
    log.info("checking for worksheets to unlock...");

    /* query all locked worksheets that have unlock_at in the past, i.e.
     * all worksheets that need to be unlocked right now. */
    jdbc.query(/*from  w w w .  ja v  a2 s. c  om*/
            "SELECT id,unlock_at FROM worksheet " + "WHERE NOT unlocked " + "AND unlock_at IS NOT NULL "
                    + "AND unlock_at <= NOW()",

            new RowCallbackHandler() {

                @Override
                public void processRow(ResultSet rs) throws SQLException {
                    int id = rs.getInt("id");
                    Date unlockAt = rs.getTimestamp("unlock_at");

                    log.info("unlocking worksheet {} with unlock_at = {}", id, unlockAt);

                    try {
                        worksheetUnlockEmailService.unlockWorksheetAndSendEmail(id);
                    } catch (MessagingException e) {
                        log.error("failed to send email", e);
                    }
                }
            });
}

From source file:dk.nsi.minlog.ws.web.IsAlive.java

/**
 * Checks if we have access to the database by doing a simple query.
 *
 * @param out Writes out the result to this jsp writer.
 * @throws IOException// ww  w .j  a  va2s .c o  m
 * @throws SQLException
 */
public void checkAll(JspWriter out) throws IOException, SQLException {
    Statement statement = null;
    Connection connection = null;

    try {
        // Checking database connection
        connection = dataSource.getConnection();
        statement = connection.createStatement();

        ResultSet rs = statement.executeQuery("SELECT 1");
        if (!rs.next() || rs.getInt(1) != 1) {
            throw new RuntimeException("Invalid result from database");
        }
    } finally {
        try {
            if (statement != null)
                statement.close();
        } finally {
            if (connection != null)
                connection.close();
        }
    }
}

From source file:com.dai.jdbc.EquipaAdversariaExtractor.java

public EquipaAdversaria extractData(ResultSet resultSet) throws SQLException, DataAccessException {
    EquipaAdversaria ea = new EquipaAdversaria();
    ea.setIdEquipaAdversaria(resultSet.getInt("idEquipaAdversaria"));
    ea.setNome(resultSet.getString("nomeEquipaAdversaria"));
    ea.setidEscalao(resultSet.getInt("escalao_idEscalao_ea"));

    return ea;//from w  w  w .j a v a  2 s .co  m
}

From source file:com.persistent.cloudninja.mapper.MeteringTotalsEntityRowMapper.java

@Override
public Usage mapRow(ResultSet rs, int row) throws SQLException {

    Usage mte = new Usage();

    mte.setYear(rs.getInt("Year"));

    mte.setMonth(rs.getInt("Month"));

    mte.setDay(rs.getInt("Day"));

    mte.setDatabaseSize(rs.getLong("DatabaseSize"));

    mte.setDatabaseBandwidth_Ingress(rs.getLong("DatabaseBandwidth_Ingress"));

    mte.setDatabaseBandwidth_Egress(rs.getLong("DatabaseBandwidth_Egress"));

    mte.setWebAppBandwithUse_SC(rs.getLong("WebAppBandwithUse_SC"));

    mte.setWebAppBandwithUse_CS(rs.getLong("WebAppBandwithUse_CS"));

    mte.setWebAppRequests(rs.getLong("WebAppRequests"));

    mte.setBlobStoreUsage(rs.getLong("BlobStoreUsage"));

    return mte;/*from  ww w  .  j  ava 2  s .  com*/
}

From source file:net.freechoice.model.orm.Map_Tag.java

@Override
public FC_Tag mapRow(final ResultSet rs, int rowNum) throws SQLException {

    FC_Tag tag = new FC_Tag();

    tag.id = rs.getInt(1);
    tag.num_tagged = rs.getInt(2);/*w w w  .  j av  a 2 s. c o  m*/
    tag.content = rs.getString(3);

    return tag;
}

From source file:com.lanacion.adminsiteln.dao.infografiasrepository.InfografiaMapper.java

public InfografiaDocument mapRow(ResultSet rs, int rowNum) throws SQLException {
    InfografiaDocument infografia = new InfografiaDocument();
    infografia.setIdInfografia(rs.getInt("idInfografia"));
    infografia.setTitulo(rs.getString("titulo"));
    infografia.setDescripcion(rs.getString("descripcion"));
    infografia.setEstado(rs.getInt("estado"));
    infografia.setTipo_infografia(rs.getInt("tipo_infografia"));
    infografia.setFecha_creacion(rs.getDate("fecha_creacion"));
    infografia.setFecha_modificacion(rs.getDate("fecha_modificacion"));
    return infografia;
}

From source file:com.persistent.cloudninja.mapper.InstanceHealthKpiRowMapper.java

@Override
public InstanceHealthKPIEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
    InstanceHealthKPIEntity kpiType = new InstanceHealthKPIEntity();
    kpiType.setKpiId(rs.getInt("KpiTypeId"));
    kpiType.setKpiName(rs.getString("Name"));
    return kpiType;
}

From source file:com.softserveinc.internetbanking.model.mapper.MoneyTransactionRowMapper.java

@Override
public MoneyTransaction mapRow(ResultSet rs, int i) throws SQLException {
    MoneyTransaction moneyTransaction = new MoneyTransaction();
    moneyTransaction.setAccount_id(rs.getInt("account_id"));
    moneyTransaction.setDateTime(rs.getString("date_time"));
    moneyTransaction.setDestination_account_id(rs.getInt("destination_account_id"));
    moneyTransaction.setTransactionAmount(rs.getBigDecimal("amount"));
    moneyTransaction.setTransactionId(rs.getInt("transaction_id"));
    return moneyTransaction;
}

From source file:edu.pitt.sis.infsci2730.finalProject.utils.TransactionRowMapper.java

public TransactionDBModel mapRow(ResultSet rs, int index) throws SQLException {
    TransactionDBModel transaction = new TransactionDBModel();

    transaction.setTransaction_id(rs.getInt("TRANSACTION_ID"));
    transaction.setTransaction_date(rs.getTimestamp("TRANSACTION_DATE"));
    transaction.setCustomer_id(rs.getInt("CUSTOMER_ID"));
    //        transaction.setSalesperson_id(rs.getInt("SALESPERSON_ID"));

    return transaction;
}

From source file:org.openmrs.module.bahmniexports.example.domain.trade.internal.CustomerCreditRowMapper.java

@Override
public CustomerCredit mapRow(ResultSet rs, int rowNum) throws SQLException {
    CustomerCredit customerCredit = new CustomerCredit();

    customerCredit.setId(rs.getInt(ID_COLUMN));
    customerCredit.setName(rs.getString(NAME_COLUMN));
    customerCredit.setCredit(rs.getBigDecimal(CREDIT_COLUMN));

    return customerCredit;
}