Esempio n. 1
0
  public static int addBook(Book book) throws Exception {
    int intStat = 0;

    if (null != book.getIsbn10()) {
      book.setIsbn13(IsbnUtil.convert(book.getIsbn10()));
    } else {
      book.setIsbn10(IsbnUtil.convert(book.getIsbn13()));
    }

    String sql =
        "INSERT INTO Books (ISBN10, ISBN13, Title, Author, "
            + "Edition, Publisher, Description, YearPublish, "
            + "Copies) VALUES (?,?,?,?,?,?,?,?,?)";

    PreparedStatement ps = Connector.getConnection().prepareStatement(sql);
    ps.setString(1, book.getIsbn10());
    ps.setString(2, book.getIsbn13());
    ps.setString(3, book.getTitle());
    ps.setString(4, book.getAuthor());
    ps.setString(5, book.getEdition());
    ps.setString(6, book.getPublisher());
    ps.setString(7, book.getDescription());
    ps.setInt(8, book.getYearPublish());
    ps.setInt(9, book.getCopies());

    intStat = ps.executeUpdate();

    Connector.close();

    return intStat;
  }
Esempio n. 2
0
  public static int editBook(Book book) throws Exception {
    int intStat = 0;

    String sql =
        "UPDATE Books SET ISBN10 = ?, ISBN13 = ?, "
            + "Title = ?, Author = ?, Edition = ?, Publisher = ?, "
            + "Description = ?, YearPublish = ?, Copies = ? "
            + "WHERE ID = ?";

    PreparedStatement ps = Connector.getConnection().prepareStatement(sql);

    ps.setString(1, book.getIsbn10());
    ps.setString(2, book.getIsbn13());
    ps.setString(3, book.getTitle());
    ps.setString(4, book.getAuthor());
    ps.setString(5, book.getEdition());
    ps.setString(6, book.getPublisher());
    ps.setString(7, book.getDescription());
    ps.setInt(8, book.getYearPublish());
    ps.setInt(9, book.getCopies());
    ps.setInt(10, book.getBookId());

    intStat = ps.executeUpdate();

    Connector.close();

    return intStat;
  }
Esempio n. 3
0
 public OwnedBook(Book book) {
   super(
       book.getId(),
       book.getGoodreadsId(),
       book.getAuthorName(),
       book.getGoodreadsAuthorId(),
       book.getName(),
       book.getIsbn(),
       book.getIsbn13(),
       book.getPublishedYear(),
       book.getDescription(),
       book.getPublisher(),
       book.getNumberOfPages(),
       book.getImageUrl());
   setBookType(book.getBookType());
 }