42 |
|
|
43 |
} |
} |
44 |
|
|
45 |
|
List<SavedStatBean> convertResultset(ResultSet res) throws SQLException{ |
46 |
|
List<SavedStatBean> stats = new ArrayList<SavedStatBean>(); |
47 |
|
while (res.next()) { |
48 |
|
SavedStatBean bean = convertRow(res); |
49 |
|
stats.add(bean); |
50 |
|
|
51 |
|
} |
52 |
|
return stats; |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
57 |
|
|
59 |
try { |
try { |
60 |
conn = DBConnection.getConnection(); |
conn = DBConnection.getConnection(); |
61 |
Statement stmt = conn.createStatement(); |
Statement stmt = conn.createStatement(); |
62 |
List<SavedStatBean> stats = new ArrayList<SavedStatBean>(); |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
String sqlAvg = "SELECT count(*) AS count, round(avg(location+name+favorites),1) AS station, round(avg(location),1) as location, round(avg(name),1) as name, round(avg(favorites),1) as favorites, " + |
String sqlAvg = "SELECT count(*) AS count, round(avg(location+name+favorites),1) AS station, round(avg(location),1) as location, round(avg(name),1) as name, round(avg(favorites),1) as favorites, " + |
80 |
|
|
81 |
|
|
82 |
ResultSet res = stmt.executeQuery(SQL); |
ResultSet res = stmt.executeQuery(SQL); |
83 |
|
List<SavedStatBean> stats = convertResultset(res); |
84 |
|
|
85 |
|
|
86 |
|
////////////////////////////////////////////// |
87 |
|
|
88 |
|
SQL = "select statisticsdate,location+name+favorites AS station,location,name,favorites,departure,depcache,deperror,timetable,timecache,timeerror from trainstatistics order by departure - deperror desc limit 5"; |
89 |
|
res = stmt.executeQuery(SQL); |
90 |
|
|
91 |
while (res.next()) { |
List<SavedStatBean> top5 = convertResultset(res); |
92 |
SavedStatBean bean = convertRow(res); |
|
|
stats.add(bean); |
|
|
|
|
|
} |
|
93 |
|
|
94 |
conn.close(); |
conn.close(); |
95 |
|
|
96 |
|
|
97 |
request.setAttribute("avg", avgBean); |
request.setAttribute("avg", avgBean); |
98 |
request.setAttribute("stats", stats); |
request.setAttribute("stats", stats); |
99 |
|
request.setAttribute("top5", top5); |
100 |
request.getRequestDispatcher("/savedstatistics.jsp").forward(request, response); |
request.getRequestDispatcher("/savedstatistics.jsp").forward(request, response); |
101 |
|
|
102 |
|
|