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:edu.pitt.sis.infsci2730.finalProject.utils.RecordRowMapper.java

public RecordDBModel mapRow(ResultSet rs, int index) throws SQLException {
    RecordDBModel record = new RecordDBModel();

    record.setTransaction_id(rs.getInt("TRANSACTION_ID"));
    record.setProduct_id(rs.getInt("PRODUCT_ID"));
    record.setAmount(rs.getInt("AMOUNT"));
    record.setPrice(rs.getInt("PRICE"));

    return record;
}

From source file:com.phideltcmu.recruiter.server.dao.mapper.StatCountSetExtractor.java

@Override
public Object extractData(ResultSet rs) throws SQLException {
    InternalUserStat internalUserStat = new InternalUserStat();
    internalUserStat.setInternalID(rs.getInt("referredBy"));
    internalUserStat.setUniqueAdditions(rs.getInt("COUNT(*)"));
    return internalUserStat;
}

From source file:com.phideltcmu.recruiter.server.dao.mapper.StatZeroSetExtractor.java

@Override
public Object extractData(ResultSet rs) throws SQLException {
    InternalUserStat internalUserStat = new InternalUserStat();
    internalUserStat.setInternalID(rs.getInt("id"));
    internalUserStat.setUniqueAdditions(0);
    return internalUserStat;
}

From source file:com.springapp.mvc.mappers.VariantRowMapper.java

@Override
public Variant mapRow(ResultSet resultSet, int rowNum) throws SQLException {
    Variant variant = new Variant();

    variant.setCode(resultSet.getInt("code"));
    variant.setColor(Color.getColor(resultSet.getString("color")));
    variant.setSize(resultSet.getInt("size"));

    return variant;
}

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

public AddressDBModel mapRow(ResultSet rs, int index) throws SQLException {
    AddressDBModel address = new AddressDBModel();

    address.setAddress_id(rs.getInt("address_id"));
    address.setCity(rs.getString("city"));
    address.setState_(rs.getString("state_"));
    address.setStreet(rs.getString("street"));
    address.setZipCode(rs.getString("zipCode"));

    return address;
}

From source file:springmvc.repository.mappers.ResembleGameMapper.java

@Override
public ResembleGame mapRow(ResultSet rs, int i) throws SQLException {
    ResembleGame resembleGame = new ResembleGame();
    resembleGame.setGameId(rs.getInt("idGame"));
    resembleGame.setGamename(rs.getString("gamename"));
    resembleGame.setLearningGoal(rs.getString("learning_goals"));
    resembleGame.setInfo(rs.getString("info"));
    resembleGame.setDifficulty(rs.getInt("difficulty"));
    resembleGame.setCreatorId(rs.getString("creator_id"));
    //TASKNUMBERS?!?!?!?!        
    return resembleGame;
}

From source file:com.flexive.core.Database.java

/**
 * Loads all FxString entries stored in the given table.
 *
 * @param con     an existing connection
 * @param table   table to use//from   ww w.j  a  v  a2s . c  o m
 * @param columns name of the columns containing the translations
 * @return all FxString entries stored in the given table, indexed by the ID field.
 * @throws SQLException if the query was not successful
 */
public static Map<Long, FxString[]> loadFxStrings(Connection con, String table, String... columns)
        throws SQLException {
    Statement stmt = null;
    final StringBuilder sql = new StringBuilder();
    final Map<Long, FxString[]> result = Maps.newHashMap();
    final Map<String, String> cache = Maps.newHashMap(); // avoid return duplicate strings
    try {
        sql.append("SELECT ID, LANG");
        final boolean hasDefLang = columns.length == 1; // deflang is only meaningful for single-column tables
        if (hasDefLang)
            sql.append(", DEFLANG");
        for (String column : columns) {
            sql.append(',').append(column);
            if (!hasDefLang)
                sql.append(',').append(column).append("_MLD");
        }
        sql.append(" FROM ").append(table).append(ML).append(" ORDER BY LANG");
        final int startIndex = hasDefLang ? 4 : 3;
        stmt = con.createStatement();
        final ResultSet rs = stmt.executeQuery(sql.toString());
        while (rs.next()) {
            final long id = rs.getLong(1);
            final int lang = rs.getInt(2);
            boolean defLang = false;
            if (hasDefLang)
                defLang = rs.getBoolean(3);
            if (lang == FxLanguage.SYSTEM_ID) {
                continue; // TODO how to deal with system language? 
            }
            FxString[] entry = result.get(id);
            if (entry == null) {
                entry = new FxString[columns.length];
            }
            for (int i = 0; i < columns.length; i++) {
                final String value = rs.getString(startIndex + i * (hasDefLang ? 1 : 2));
                String translation = cache.get(value); // return cached string instance
                if (translation == null) {
                    translation = value;
                    cache.put(value, value);
                }
                if (entry[i] == null)
                    entry[i] = new FxString(true, lang, translation);
                else
                    entry[i].setTranslation(lang, translation);
                if (!hasDefLang)
                    defLang = rs.getBoolean(startIndex + 1 + i * 2);
                if (defLang)
                    entry[i].setDefaultLanguage(lang);
            }
            result.put(id, entry);
        }

        // canonicalize FxStrings (some tables, especially assignments, contain a lot of 100% identical labels for different IDs)
        final Map<FxString, FxString> fxCache = Maps.newHashMapWithExpectedSize(result.size() * 2);
        for (FxString[] values : result.values()) {
            for (int i = 0; i < values.length; i++) {
                final FxString value = values[i];
                FxString cached = fxCache.get(value);
                if (cached != null) {
                    values[i] = cached;
                } else {
                    fxCache.put(value, value);
                }
            }
        }
    } finally {
        closeObjects(Database.class, null, stmt);
    }
    return result;
}

From source file:com.ewcms.component.online.dao.CitizenDAO.java

private Citizen citizenMapRow(ResultSet rs) throws SQLException {
    Citizen citizen = new Citizen();
    citizen.setId(rs.getInt("id"));
    citizen.setName(rs.getString("citizen_name"));

    return citizen;
}

From source file:com.ewcms.content.particular.dao.FontArticleMainDAO.java

private ChannelVO channelRowMapper(ResultSet rs) throws SQLException {
    ChannelVO vo = new ChannelVO();
    vo.setId(rs.getInt("id"));
    return vo;/*from   w ww  .j  av a2 s .  co  m*/
}

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

public ProductDBModel mapRow(ResultSet rs, int index) throws SQLException {
    ProductDBModel product = new ProductDBModel();

    product.setProduct_id(rs.getInt("PRODUCT_ID"));
    product.setProduct_name(rs.getString("PRODUCT_NAME"));
    product.setInventory_amount(rs.getInt("INVENTORY_AMOUNT"));
    product.setPrice(rs.getInt("PRICE"));
    product.setCategory_id(rs.getInt("CATEGORY_ID"));
    product.setBuying_price(rs.getInt("BUYING_PRICE"));

    return product;
}