la cosa migliore è crearsi una classe wrapper personalizzata:
codice:
public class Author {
public int id;
public String name;
public Author(String name) {
this.name = name;
}
public Author(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
@Override
public String toString() {
return name;
}
}
poi ti potresti creare un ArrayList<Author> che scorri e passi alla JCB.
ad esempio lo creo da db:
codice:
public ArrayList<Author> fillAuthor() throws SQLException, ClassNotFoundException, IOException {
ArrayList<Author> list = new ArrayList<Author>();
conn = DBManager.getInstance().takeConnection();
CallableStatement cstmt = conn.prepareCall("{ CALL getAuthor() }");
ResultSet rs = cstmt.executeQuery();
while (rs.next()) {
list.add(new Author(rs.getInt("author_id"), rs.getString("author_name")));
}
cstmt.close();
return list;
}
a questo punto in ogni voce della JCB hai le propriatà del rispettivo oggetto Author.