avrei un altro problema:
codice:
public class Book {
private int book_id;
private String name;
private String author;
private String editor;
private double price;
private String isbn;
private String note;
public Book(int book_id, String name) {
this.book_id = book_id;
this.name = name;
}
public Book(int book_id, String name, String author, String editor, double price, String isbn, String note) {
this.book_id = book_id;
this.name = name;
this.author = author;
this.editor = editor;
this.price = price;
this.isbn = isbn;
this.note = note;
}
public int getBookId() {
return book_id;
}
public String getName() {
return name;
}
public String getAuthor() {
return author;
}
public String getEditor() {
return editor;
}
public double getPrice() {
return price;
}
public String getIsbn() {
return isbn;
}
public String getNote() {
return note;
}
}
metodo per riempir:
codice:
public class DoFillBookId {
public static ArrayList fillBook() throws SQLException, ClassNotFoundException {
ArrayList list = new ArrayList();
Connection conn = DoConnection.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM book");
while (rs.next()) {
list.add(new Book(rs.getInt("book_id"), rs.getString("name")));
}
rs.close();
stmt.close();
return list;
}
}
poi nel frame:
codice:
private void fillBookId() throws SQLException, ClassNotFoundException {
comboBookId.removeAllItems();
comboBookId.addItem("*");
ArrayList list = DoFillBookId.fillBook();
for (Object obj : list) {
comboBookId.addItem(obj);
}
}
ottengo un risultato strano:
operazioni_database.Book@ec0a9f9
......
mi pare di aver fatto tutto come negli altri due casi.