Пример #1
0
 public List getBooksByCost(String cost) {
   List al = new ArrayList();
   try {
     con = JdbcUtil.getMysqlConnection();
     ps = con.prepareStatement("select *from jlcbooks where cost=?");
     ps.setString(1, cost);
     rs = ps.executeQuery();
     while (rs.next()) {
       Book bo = new Book();
       bo.setBid(rs.getString(1));
       bo.setBname(rs.getString(2));
       bo.setAuthor(rs.getString(3));
       bo.setPub(rs.getString(4));
       bo.setCost(rs.getString(5));
       bo.setEdi(rs.getString(6));
       bo.setIsbn(rs.getString(7));
       al.add(bo);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     JdbcUtil.cleanup(ps, con);
   }
   return al;
 }
Пример #2
0
 public Book getBookByBid(String bid) {
   Book bo = null;
   try {
     con = JdbcUtil.getMysqlConnection();
     ps = con.prepareStatement("select *from jlcbooks where bid=?");
     ps.setString(1, bid);
     rs = ps.executeQuery();
     if (rs.next()) {
       bo = new Book();
       bo.setBid(rs.getString(1));
       bo.setBname(rs.getString(2));
       bo.setAuthor(rs.getString(3));
       bo.setPub(rs.getString(4));
       bo.setCost(rs.getString(5));
       bo.setEdi(rs.getString(6));
       bo.setIsbn(rs.getString(7));
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     JdbcUtil.cleanup(ps, con);
   }
   return bo;
 }