Instead of
null,
use CustomerDTO customers =
new CustomerDTO()`;
CustomerDTO customer = null;
private static List<Author> getAllAuthors() {
initConnection();
List<Author> authors = new ArrayList<Author>();
Author author = new Author();
try {
stmt = (Statement) conn.createStatement();
String str = "SELECT * FROM author";
rs = (ResultSet) stmt.executeQuery(str);
while (rs.next()) {
int id = rs.getInt("nAuthorId");
String name = rs.getString("cAuthorName");
author.setnAuthorId(id);
author.setcAuthorName(name);
authors.add(author);
System.out.println(author.getnAuthorId() + " - " + author.getcAuthorName());
}
rs.close();
closeConnection();
} catch (Exception e) {
System.out.println(e);
}
return authors;
}