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:com.leapfrog.project.DAO.Impl.ProductDAOImpl.java

@Override
public List<Product> getAll() throws SQLException, ClassNotFoundException {

    String sql = "SELECT * FROM product";

    return jdbcTemplate.query(sql, new RowMapper<Product>() {

        @Override/*from w w  w  . ja va  2 s .  co  m*/
        public Product mapRow(ResultSet rs, int i) throws SQLException {

            Product pro = new Product();
            pro.setId(rs.getInt("id"));
            pro.setName(rs.getString("name"));
            pro.setDescription(rs.getString("description"));
            pro.setCostPrice(rs.getInt("costPrice"));
            pro.setSellingPrice(rs.getInt("sellingPrice"));

            return pro;
        }
    });
}

From source file:com.pet.demo.repository.jdbc.JdbcVetRepositoryImpl.java

/**
 * Refresh the cache of Vets that the ClinicService is holding.
 *
 * @see org.PetDemoService.samples.petclinic.model.service.ClinicService#findVets()
 *//*  w  ww .ja v a2 s.  c o m*/
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>() {
                    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.ccinepal.springjdbc.daoimpl.StudentDAOImpl.java

@Override
public List<Student> getAll() throws SQLException {
    String sql = "Select *from student";
    return jdbcTemplate.query(sql, new RowMapper<Student>() {
        @Override// w ww  .  java2 s. c  om
        public Student mapRow(ResultSet rs, int i) throws SQLException {

            Student s = new Student();
            s.setId(rs.getInt("student_id"));
            s.setName(rs.getString("name"));

            return s;
        }
    });
}

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

@Override
public InstanceHealthActiveUserEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
    InstanceHealthActiveUserEntity uniqueUser = new InstanceHealthActiveUserEntity();
    uniqueUser.setCount(rs.getInt("ActiveUsers"));
    Timestamp time = rs.getTimestamp("TimeInterval");
    uniqueUser.setTimeStamp(new Date(time.getTime()));

    return uniqueUser;
}

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

@Override
public InstanceHealthRoleInstanceEntity mapRow(ResultSet rs, int rowNum) throws SQLException {
    InstanceHealthRoleInstanceEntity kpiRoles = new InstanceHealthRoleInstanceEntity();
    kpiRoles.setRoleId(rs.getInt("RoleId"));
    kpiRoles.setInstance(rs.getInt("Instance"));
    kpiRoles.setRoleName(rs.getString("RoleName"));
    return kpiRoles;
}

From source file:com.teamexception.reseravationmaven.mapper.ServiceVehicleTypeMapper.java

public VehicleServiceType mapRow(ResultSet rs, int rowNum) throws SQLException {
    VehicleServiceType vehicleType = new VehicleServiceType(rs.getString("vehicleName"),
            rs.getString("serviceId"), rs.getInt("duration"), rs.getDouble("cost"));
    System.out.println("ssssssssssssssssssssssssss");
    return vehicleType;
}

From source file:net.sourceforge.vulcan.spring.jdbc.BuildHistoryTopTestFailuresQuery.java

@Override
protected TestFailureDto mapRow(ResultSet rs, int rowNumber) throws SQLException {
    final TestFailureDto dto = new TestFailureDto();

    dto.setCount(rs.getInt("msg_count"));
    dto.setName(rs.getString("name"));

    return dto;//ww  w  . j  a  v a  2  s .  c  o  m
}

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:com.ccinepal.springjdbc.daoimpl.StudentDAOImpl.java

@Override
public Student getById(int id) throws SQLException {

    String sql = "select *from student where student_id=? ";
    return jdbcTemplate.queryForObject(sql, new RowMapper<Student>() {
        @Override//from   w w w.j av  a 2  s  .  c o m
        public Student mapRow(ResultSet rs, int i) throws SQLException {

            Student s = new Student();
            s.setId(rs.getInt("student_id"));
            s.setName(rs.getString("name"));
            return s;
        }
    }, new Object[] { id });

}

From source file:lcn.module.batch.web.guide.service.CustomerCreditRowMapper.java

/**
 * CustomerCredit VO set/*from  w  ww .  j  a v a  2  s.c  o  m*/
 */
public Object 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;
}