KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
11  * @author Eitan Suez
12  */

13 public class StatsClasses extends Page
14 {
15    public StatsClasses()
16    {
17       super();
18    }
19    
20    public String JavaDoc handleRequest() throws SQLException
21    {
22       List stats = getClassStats();
23       request.setAttribute("classCounts", stats);
24       return null;
25    }
26    
27
28    /**
29     * contrasting this implementation with the author stats -- author stats
30     * are ordered by count whereas class stats (really package stats) are
31     * ordered alphabetically while large packages are highlighted. not sure
32     * which is more desirable. something to think about.
33     */

34    public List getClassStats() throws SQLException
35    {
36       /*
37       String sql =
38          "select p.name, p.id, count(*) " +
39          " from classtype c, package p" +
40          " where c.packageid=p.id " +
41          " group by p.name order by p.name";
42        */

43       
44       String JavaDoc sql = DBMgr.getInstance().getStatement("classstats");
45
46       Statement stmt = conn.createStatement();
47       ResultSet rset = stmt.executeQuery(sql);
48       
49       List stats = new ArrayList(100);
50       
51       List info = null;
52       
53       JPackage pkg = null;
54       while (rset.next())
55       {
56          info = new ArrayList(2);
57          pkg = new JPackage(rset.getString(1));
58          pkg.setId(rset.getInt(2));
59          info.add(pkg);
60          info.add(rset.getString(3));
61          stats.add(info);
62       }
63       
64       return stats;
65    }
66    
67    
68 }
69
Popular Tags