예제 #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 int verifyUser(String un, String pw) {
    int x = 0;
    try {
      con = JdbcUtil.getMysqlConnection();
      ps = con.prepareStatement("select * from user_table where username=? and password=?");
      ps.setString(1, un);
      ps.setString(2, pw);
      rs = ps.executeQuery();
      if (rs.next()) {
        x = 1;
      }

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      JdbcUtil.cleanup(ps, con, rs);
    }
    return x;
  }
예제 #3
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;
 }