List of usage examples for java.sql ResultSet getInt
int getInt(String columnLabel) throws SQLException;
ResultSet
object as an int
in the Java programming language. From source file:com.epam.repository.author.AuthorRepository.java
public List<Author> findAll() { return jdbcTemplate.query(GET_ALL_AUTHORS, new RowMapper<Author>() { public Author mapRow(ResultSet rs, int rowNum) throws SQLException { Author author = new Author(); author.setId(rs.getInt("ID")); author.setName(rs.getString("Name")); author.setSurname(rs.getString("Surname")); return author; }//from w ww . ja v a 2s .com }); }
From source file:com.mesut.daopattern.OffersDAO.java
/** * Gets List of offers with jdbc template<br/> * <strong>sql query:</strong> <code>select * from offers</code> * @return List<Offer> //from ww w .j av a 2 s . c o m * @see List * @see Offer */ public List<Offer> findOffers() { return jdbc.query("select * from offers", new RowMapper<Offer>() { public Offer mapRow(ResultSet rs, int i) throws SQLException { Offer offer = new Offer(); offer.setId(rs.getInt("id")); offer.setName(rs.getString("name")); offer.setEmail(rs.getString("email")); offer.setText(rs.getString("text")); return offer; } }); }
From source file:com.rambird.miles.repository.jdbc.JdbcVetRepositoryImpl.java
/** * Refresh the cache of Vets that the ClinicService is holding. * <<<<<<< HEAD/*w w w . j a v a2 s . com*/ * @see org.springframework.samples.petclinic.model.RambirdService.ClinicService#findVets() ======= * @see org.springframework.samples.petclinic.model.service.ClinicService#findVets() >>>>>>> origin/master */ @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:fp4f.floorplans.DatabaseLayer.java
HouseItem getHouse(AddressItem selected) { HouseItem house = new HouseItem(); try {/* w ww.j a va2s . c o m*/ PreparedStatement getter = con.prepareStatement("select * from houses where id = ?"); getter.setInt(1, selected.HouseId); ResultSet rs = getter.executeQuery(); house.Id = rs.getInt("id"); house.Address = rs.getString("address"); house.Phone = rs.getString("phone"); house.Adults = rs.getInt("adults"); house.Children = rs.getInt("children"); house.Elderly = rs.getInt("elderly"); house.Pets = rs.getInt("pets"); house.Salvage = rs.getInt("salvage"); house.Complexity = rs.getInt("complexity"); house.Weapons = rs.getBoolean("weapons"); house.Disabilities = rs.getString("disability"); house.Combustables = rs.getString("combustables"); house.Community = rs.getString("community"); house.Floors = getFloors(house.Id); } catch (Exception ex) { System.out.println(ex); } return house; }
From source file:com.leapfrog.inventorymanagementsystem.dao.impl.SupplierDAOImpl.java
@Override public Supplier getById(int id) throws SQLException, ClassNotFoundException { String sql = "SELECT * FROM tbl_supplier WHERE supplier_id =?"; return jdbcTemplate.queryForObject(sql, new Object[] { id }, new RowMapper<Supplier>() { @Override/* www . ja v a 2 s . com*/ public Supplier mapRow(ResultSet rs, int i) throws SQLException { Supplier s = new Supplier(); s.setId(rs.getInt("supplier_id")); s.setSupplierName(rs.getString("supplier_name")); s.setAddress(rs.getString("address")); s.setContact(rs.getString("contact")); s.setEmail(rs.getString("email")); s.setAddedDate(rs.getDate("added_date")); s.setStatus(rs.getBoolean("status")); return s; } }); }
From source file:com.magrocode.bm.service.dao.jdbc.SmtpConfigDaoImpl.java
@Override public SmtpConfigTo[] getAll() { String sql = "SELECT * FROM SMTP_CONFIG;"; return (SmtpConfigTo[]) jdbcTemplate.query(sql, new RowMapper<SmtpConfigTo>() { @Override/* ww w . java 2 s . c om*/ public SmtpConfigTo mapRow(ResultSet rs, int i) throws SQLException { SmtpConfigTo c = new SmtpConfigTo(); c.setId(rs.getInt("SMTP_CONFIG_ID")); c.setCompanya_id(rs.getInt("COMPANYA_ID")); c.setHost(rs.getString("SMTP_HOST")); c.setPort(rs.getInt("SMTP_PORT")); c.setAuth(rs.getBoolean("SMTP_AUTH")); c.setEmail(rs.getString("SMTP_EMAIL")); c.setUsername(rs.getString("SMTP_USERNAME")); c.setPassword(rs.getString("SMTP_PASSWORD")); return c; } }).toArray(new SmtpConfigTo[] {}); }
From source file:com.mesut.daopattern.OffersDAO.java
public Offer findById(int id) { MapSqlParameterSource params = new MapSqlParameterSource(); params.addValue("id", id); return jdbc.queryForObject("select * from offers where id= :id", params, new RowMapper<Offer>() { public Offer mapRow(ResultSet rs, int i) throws SQLException { Offer offer = new Offer(); offer.setId(rs.getInt("id")); offer.setName(rs.getString("name")); offer.setEmail(rs.getString("email")); offer.setText(rs.getString("text")); return offer; }//from w ww . j a v a2s.c o m }); }
From source file:com.persistent.cloudninja.mapper.TenantUsageRowMapper.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.setDay(rs.getInt("Day")); 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.rakesh.rp3599.repository.ApplicationRepository.java
public Application findByName(String name) { return jdbcTemplate.queryForObject(ApplicationUtil.SELECT_AGENCY_BY_NAME, new Object[] { name }, new RowMapper<Application>() { public Application mapRow(ResultSet rs, int rowNum) throws SQLException { Application e = new Application(); e.setId(rs.getInt("id")); e.setCompanyName(rs.getString("company_name")); return e; }//from w ww. j a v a 2 s .c o m }); }
From source file:net.freechoice.model.orm.Map_Profile.java
@Override public FC_Profile mapRow(final ResultSet rs, int arg1) throws SQLException { FC_Profile prof = new FC_Profile(); prof.id = rs.getInt(1); prof.id_user_ = rs.getInt(2);//from w w w. j a v a 2 s .c o m prof.date_register = rs.getDate(3); prof.site_personal = rs.getString(4); prof.name_first = rs.getString(5); prof.name_last = rs.getString(6); prof.contact_public = rs.getString(7); prof.gender = rs.getBoolean(8); prof.date_birth = rs.getDate(9); return prof; }