I am writing code that uses JDBC to access and creates one Book object for each row in the table. The book objects should be stored in a java.util.List implementation. How do I provide a method that returns a reference to that list. How do I print out the content of that list after creating all books
public synchronized void excuteQuery() throws SQLException{
final String QUERY =
"SELECT TITLE, AUTHOR FROM BOOKS";
Statement statement = conn.createStatement() ;
ResultSet results = statement.executeQuery(QUE
RY);
while(results.next()){
JDBCBook book = new JDBCBook(results.getString
(1), results.getString(2));
bookList.add(book);
}
results.close();
statement.close();
}
Start Free Trial