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:Poll_Ans_Tbl.Poll_Ans_Tbl_Mapper.java

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

    Poll_Ans_Tbl poll_ans_tbl = new Poll_Ans_Tbl();
    poll_ans_tbl.setPid(rs.getInt("pid"));
    poll_ans_tbl.setPoll_ans_key(rs.getInt("poll_ans_key"));

    poll_ans_tbl.setSolve_ts(rs.getString("solve_ts"));
    poll_ans_tbl.setQtn(rs.getString("ans_json"));
    poll_ans_tbl.setGeo_json(rs.getString("geolocation_json"));
    int anonymous = rs.getInt("anonymous");
    poll_ans_tbl.setAnonymous(anonymous);
    User_Detail user = new User_Detail();
    if (anonymous == 0) {
        poll_ans_tbl.setUid(rs.getInt("uid"));
        User_TblJDBCTemplate user_jdbc = new User_TblJDBCTemplate();
        user = user_jdbc.get_profile(rs.getInt("uid"));
        poll_ans_tbl.setUser(user);/*from  w  w  w .  j a  va 2  s. c  o  m*/
    } else {//if the user solved poll anonymously
        poll_ans_tbl.setUid(0);
        user.setName("Anonymous-" + count);
        user.setHandle("Anonymous-" + count);
        user.setUid(0);
        user.setProfile_pic("pages/resources/images/profile/anonymous.jpg");
        poll_ans_tbl.setUser(user);
        count++;
    }

    return poll_ans_tbl;
}

From source file:com.neupane.springJDBC.DAO.Impl.CustomerDAOImpl.java

@Override
public List<Customer> getAll() throws ClassNotFoundException, SQLException {
    String sql = "SELECT * FROM customer";
    return jdbcTemplet.query(sql, new RowMapper<Customer>() {

        @Override/*from   w  w w  .j a v a2s .c  o  m*/
        public Customer mapRow(ResultSet rs, int i) throws SQLException {
            Customer cust = new Customer();
            cust.setCustomerId(rs.getInt("id"));
            cust.setFirstName(rs.getString("first_name"));
            cust.setLastName(rs.getString("last_name"));
            cust.setAddress(rs.getString("address"));
            cust.setEmail(rs.getString("email"));
            cust.setContact(rs.getInt("contact"));
            cust.setStatus(Boolean.parseBoolean(rs.getString("status")));
            return cust;
        }
    });
}

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

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

    FC_Post post = new FC_Post();

    post.id = rs.getInt(1);
    post.status = rs.getShort(2);//from   w w  w.j  a v  a  2  s  .  c o m
    post.id_author = rs.getInt(3);
    post.name_author = rs.getString(4);
    post.time_posted = rs.getTimestamp(5);
    post.num_read = rs.getInt(6);
    post.num_comment = rs.getInt(7);
    post.title = rs.getString(8);
    post.content = rs.getString(9);

    return post;
}

From source file:com.havoc.hotel.admin.dao.impl.UserDAOImpl.java

private User mapData(ResultSet rs) throws SQLException {
    User u = new User();
    u.setUserId(rs.getInt("user_id"));
    u.setFirstName(rs.getString("first_name"));
    u.setLastName(rs.getString("last_name"));
    u.setEmail(rs.getString("email"));
    u.setUsername(rs.getString("username"));
    u.setPassword(rs.getString("password"));
    u.setRoleId(rs.getInt("role_id"));
    u.setAddedDate(rs.getDate("added_date"));
    u.setStatus(rs.getBoolean("status"));
    return u;//w  w w .j  ava  2s. c  o  m
}

From source file:lcn.samples.petclinic.repository.jdbc.JdbcVetRepositoryImpl.java

/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see lcn.samples.petclinic.service.service.ClinicService#findVets()
 *///  www  .  ja  v a 2 s.  c  om
@Override
public Collection<Vet> findAll() throws DataAccessException {

    List<Vet> vets = new ArrayList<Vet>();
    // Retrieve the list of all vets.
    vets.addAll(
            this.jdbcTemplate.query("SELECT id, first_name, last_name FROM vets ORDER BY last_name,first_name",
                    ParameterizedBeanPropertyRowMapper.newInstance(Vet.class)));

    // Retrieve the list of all possible specialties.
    final List<Specialty> specialties = this.jdbcTemplate.query("SELECT id, name FROM specialties",
            ParameterizedBeanPropertyRowMapper.newInstance(Specialty.class));

    // Build each vet's list of specialties.
    for (Vet vet : vets) {
        final List<Integer> vetSpecialtiesIds = this.jdbcTemplate.query(
                "SELECT specialty_id FROM vet_specialties WHERE vet_id=?",
                new ParameterizedRowMapper<Integer>() {
                    @Override
                    public Integer mapRow(ResultSet rs, int row) throws SQLException {
                        return Integer.valueOf(rs.getInt(1));
                    }
                }, vet.getId().intValue());
        for (int specialtyId : vetSpecialtiesIds) {
            Specialty specialty = EntityUtils.getById(specialties, Specialty.class, specialtyId);
            vet.addSpecialty(specialty);
        }
    }
    return vets;
}

From source file:com.javacodegags.waterflooding.model.ParametersImplemented.java

@Override
public List<Parameters> getListById(int parameterId) {
    String sql = "SELECT * " + "FROM parameters " + "INNER JOIN criteria "
            + "ON parameters.foreign_to_criteria=criteria.Id " + "Where parameters.foreign_to_criteria="
            + parameterId + ";";
    List<Parameters> listParameters = jdbcTemplate.query(sql, new RowMapper<Parameters>() {
        @Override// ww w. ja  v  a 2s .c o m
        public Parameters mapRow(ResultSet rs, int rowNum) throws SQLException {
            Parameters parameters = new Parameters();
            parameters.setId(rs.getInt("id"));
            parameters.setName(rs.getString("name"));
            parameters.setValue(rs.getFloat("value"));
            parameters.setForeignId(rs.getInt("foreign_to_criteria"));
            return parameters;
        }
    });
    return listParameters;
}

From source file:com.pagodalabs.institute.dao.impl.CourseDAOImpl.java

@Override
public List<Course> getAll() {
    String sql = "SELECT * FROM courses";
    List<Course> courseList = jdbcTemplate.query(sql, new RowMapper<Course>() {

        @Override//from w ww .jav a2s .c  o m
        public Course mapRow(ResultSet rs, int i) throws SQLException {
            Course course = new Course();
            course.setId(rs.getInt("course_id"));
            course.setName(rs.getString("course_name"));
            course.setDescription(rs.getString("course_description"));
            course.setStatus(rs.getBoolean("status"));
            return course;
        }
    });
    return courseList;
}

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

@Override
public Usage mapRow(ResultSet rs, int rowNum) throws SQLException {
    Usage usage = new Usage();
    usage.setTenantId(rs.getString("TenantId"));
    usage.setYear(rs.getInt("Year"));
    usage.setMonth(rs.getInt("Month"));
    usage.setDatabaseSize(rs.getLong("DatabaseSize"));
    usage.setDatabaseBandwidth_Ingress(rs.getLong("DatabaseBandwidth_Ingress"));
    usage.setDatabaseBandwidth_Egress(rs.getLong("DatabaseBandwidth_Egress"));
    usage.setWebAppBandwithUse_CS(rs.getLong("WebAppBandwithUse_CS"));
    usage.setWebAppBandwithUse_SC(rs.getLong("WebAppBandwithUse_SC"));
    usage.setWebAppRequests(rs.getLong("WebAppRequests"));
    usage.setBlobStoreUsage(rs.getLong("BlobStoreUsage"));
    usage.setTotalRequestPacketSize(rs.getLong("TotalRequestPacketSize"));
    usage.setTotalResponsePacketSize(rs.getLong("TotalResponsePacketSize"));
    usage.setTotalStorageTransactions(rs.getLong("TotalStorageTransactions"));
    return usage;
}

From source file:com.l2jfree.gameserver.datatables.RecordTable.java

private void load() {
    Connection con = null;/*  ww  w  .j a v a 2 s. c o m*/
    try {
        con = L2DatabaseFactory.getInstance().getConnection();

        PreparedStatement statement = con
                .prepareStatement("SELECT maxplayer, date FROM record ORDER BY maxplayer DESC LIMIT 1");
        ResultSet rset = statement.executeQuery();

        if (rset.next()) {
            _record = rset.getInt("maxplayer");
            _date = rset.getString("date");
        }

        rset.close();
        statement.close();
    } catch (Exception e) {
        _log.warn("", e);
    } finally {
        L2DatabaseFactory.close(con);
    }
}

From source file:com.eftech.wood.phone.iphone.IphoneMapper.java

@Override
public Iphone mapRow(ResultSet rs, int i) throws SQLException {
    Iphone iphone = new Iphone();
    iphone.setId(rs.getInt("id"));
    iphone.setModel(rs.getString("model"));
    iphone.setManufacturer(rs.getString("manufacturer"));
    iphone.setYear(rs.getInt("year"));
    iphone.setType(rs.getString("type"));
    iphone.setOs(rs.getString("os"));
    iphone.setDisplay_size(rs.getInt("display_size"));
    iphone.setDisplay_resolution(rs.getString("display_resolution"));
    iphone.setRam_memory(rs.getInt("ram_memory"));
    iphone.setFlash_memory(rs.getInt("flash_memory"));
    iphone.setSim_several(rs.getString("sim_several"));
    iphone.setCamera(rs.getString("camera"));
    iphone.setMatrix_points(rs.getInt("matrix_points"));
    iphone.setDesign_case(rs.getString("design_case"));
    iphone.setMaterial(rs.getString("material"));
    iphone.setColor(rs.getString("color"));
    iphone.setSim_format(rs.getString("sim_format"));
    iphone.setDimensions(rs.getString("dimensions"));
    iphone.setWeight(rs.getInt("weight"));
    iphone.setBattery_type(rs.getString("battery_type"));
    iphone.setBattery_capacity(rs.getInt("battery_capacity"));
    iphone.setTime_talk(rs.getInt("time_talk"));
    iphone.setTime_out(rs.getInt("time_out"));
    iphone.setPrice(rs.getInt("price"));
    iphone.setDescription(rs.getString("description"));
    iphone.setPhoto1(rs.getString("photo1"));
    iphone.setPhoto2(rs.getString("photo2"));
    iphone.setPhoto3(rs.getString("photo3"));
    return iphone;
}