예제 #1
0
 public int update(BookForm bookForm) {
   String sql =
       "Update titles set typeid="
           + bookForm.getTypeId()
           + ", title='"
           + bookForm.getTitle()
           + "'"
           + ",author='"
           + bookForm.getAuthor()
           + "',translator='"
           + bookForm.getTranslator()
           + "',price="
           + bookForm.getPrice()
           + ",page="
           + bookForm.getPage()
           + " where isbn='"
           + bookForm.getIsbn()
           + "'";
   int falg = conn.executeUpdate(sql);
   conn.close();
   return falg;
 }
예제 #2
0
  // add book info
  public int insert(BookForm bookForm) {

    String sql = "";
    int falg = findTitle(bookForm.getIsbn());
    try {
      if (falg != 2 && falg != 0) {
        sql =
            "Insert into titles (isbn,title,typeid,author,translator,price,page,inTime,operator) values('"
                + bookForm.getIsbn()
                + "','"
                + bookForm.getTitle()
                + "',"
                + bookForm.getTypeId()
                + ",'"
                + bookForm.getAuthor()
                + "','"
                + bookForm.getTranslator()
                + "','"
                + bookForm.getPrice()
                + "','"
                + bookForm.getPage()
                + "','"
                + bookForm.getInTime()
                + "','"
                + bookForm.getOperator()
                + "')";
        falg = conn.executeUpdate(sql);
      }

    } catch (Exception ex) {
      falg = 0;
    } finally {
      conn.close();
    }
    System.out.println("falg:" + falg);
    return falg;
  }