Advertisement

12.09.2003 at 11:10PM PST, ID: 20821506
[x]
Attachment Details

Printing out the content of the List

Asked by dkim18 in Java Programming Language

Tags: printing, contents, list, out

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(QUERY);
     while(results.next()){
       JDBCBook book = new JDBCBook(results.getString(1), results.getString(2));
       bookList.add(book);
     }
     results.close();
     statement.close();
   }Start Free Trial
 
Loading Advertisement...
 
[+][-]12.09.2003 at 11:15PM PST, ID: 9910317

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: printing, contents, list, out
Sign Up Now!
Solution Provided By: yongsing
Participating Experts: 1
Solution Grade: A
 
 
[+][-]12.09.2003 at 11:34PM PST, ID: 9910375

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.09.2003 at 11:38PM PST, ID: 9910384

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32