Exemplo n.º 1
0
 public boolean addBookToAuthor(Author author, Book book) throws SQLException {
   PreparedStatement stmt =
       getConnection().prepareStatement("INSERT INTO Books_has_authors VALUES(?,?);");
   stmt.setInt(1, book.getId_book());
   stmt.setInt(2, author.getId_author());
   int rs = stmt.executeUpdate();
   return rs != 0;
 }
Exemplo n.º 2
0
 public boolean deleteBook(Book book) throws SQLException {
   PreparedStatement stmt = getConnection().prepareStatement("DELETE FROM Books WHERE id_book=?;");
   stmt.setInt(1, book.getId_book());
   int rs = stmt.executeUpdate();
   return rs != 0;
 }