KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > pages > AuthorsPage


1 package org.ashkelon.pages;
2
3 import org.ashkelon.*;
4 import org.ashkelon.db.*;
5
6 import java.util.*;
7 import java.sql.*;
8
9 /**
10  * @author Eitan Suez
11  */

12 public class AuthorsPage extends Page
13 {
14    public AuthorsPage()
15    {
16       super();
17    }
18    
19    public String JavaDoc handleRequest() throws SQLException
20    {
21       List authors = getAuthors();
22       request.setAttribute("authors", authors);
23       return null;
24    }
25    
26    
27    public List getAuthors() throws SQLException
28    {
29       String JavaDoc sql = DBMgr.getInstance().getStatement("getallauthors");
30       PreparedStatement p = conn.prepareStatement(sql);
31       ResultSet rset = p.executeQuery();
32
33       List authors = new ArrayList(50);
34       Author author;
35       
36       while (rset.next())
37       {
38         author = new Author(rset.getString(2));
39         author.setId(rset.getInt(1));
40         authors.add(author);
41       }
42       rset.close();
43       p.close();
44       
45       return authors;
46    }
47    
48 }
49
50
Popular Tags