Advertisement
Guest User

get

a guest
Oct 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. public Coffee get(String name) {
  2. String sql = "SELECT COF_NAME SUP_ID, PRICE, SALES, TOTAL FROM COFFEES "
  3. + "WHERE COF_NAME = :cof_name";
  4. MapSqlParameterSource params = new MapSqlParameterSource("cof_name", name);
  5. return jdbc.query(sql, params, new ResultSetExtractor<Coffee>() {
  6.  
  7. @Override
  8. public Coffee extractData(ResultSet rs) throws SQLException, DataAccessException {
  9.  
  10. while(rs.next()){
  11. String nazwa=rs.getString("COF_NAME");
  12. int supplierID = rs.getInt("sup_id");
  13. BigDecimal price = rs.getBigDecimal("PRICE");
  14. int sales = rs.getInt("SALES");
  15. int total = rs.getInt("TOTAL");
  16. Coffee temp= new Coffee("",supplierID,price,sales,total);
  17. System.out.println("COF_NAME"+""+"SUP_ID"+supplierID+"PRICE"+price+"SALES"+sales+"TOTAL"+total);
  18. return temp;
  19. }
  20. //throw new UnsupportedOperationException("Not implemented yet.");}
  21. return null;
  22. }
  23. });
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement