|
//获取请求集中的时间段:返回时间+数量 public String getHighestHour(String where) throws SQLException {
DbConnectionPool db = new DbConnectionPool();
ResultSet rs=null;
String strSql = "select to_char(requesttime,'yyyy-mm-dd hh24') requesttime,count(*) total from audit_extranet_log where 1=1 ";
strSql += where;
strSql = strSql + " group by to_char(requesttime,'yyyy-mm-dd hh24') order by count(*) desc";
String time = "";
int count = 0;
try {
System.out.println(strSql);
rs=db.executeQuery(strSql);
if(rs.next()){
time = rs.getString("requesttime");
count = rs.getInt("total");
}
} catch (Exception e) {
e.printStackTrace();
}finally{
rs.close();
db.closeConn();
}
return time + "时之后的一个小时内,请求数为:" +count ;
}
具体的JSP就不再说明,通过上述两个方法,配合页面参数,最后组合的查询类似如下(下面的情况只输入了开始时间):
select to_char(requesttime,'yyyy-mm-dd-hh24') requesttime,count(*)
from audit_admin_log
where requesttime > to_date('2007-04-06 16:25:15','yyyy-mm-dd hh24: mi: ss')
group by to_char(requesttime,'yyyy-mm-dd-hh24') order by count(*) desc;
|
|
|