public void addBook(String username, Book book) { Connection connection = null; try { connection = getConnection(); PreparedStatement statement = connection.prepareStatement( "insert into " + username + " (title, author, category, year, color, level, availability)" + " values (?, ?, ?, ?, ?, ?, ?)"); statement.setString(1, book.getTitle()); statement.setString(2, book.getAuthor()); statement.setString(3, book.getCategory()); statement.setInt(4, book.getYear()); statement.setString(5, book.getColor()); statement.setInt(6, book.getLevel()); statement.setString(7, book.getAvailability()); statement.executeUpdate(); } catch (SQLException ex) { ex.printStackTrace(); } finally { closeConnection(connection); } }