<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*"
errorPage="" %><html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>HttpDate数据统计</title>
<script src="<%=request.getContextPath()%>/tejs.js"></script>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" method="post" action="test.jsp" >
<table cellspacing="1" cellpadding="3" width="100%" border="0px">
<tr>
<td class="td_title" colspan="4" height="25px">HttpDate数据统计</td>
</tr>
<tr>
<td class="forumRowHighlight" colspan="4" style="height: 24px">统计时间:
<input name="stdate" value="2009-08-01" onclick="javascript:ShowCalendar(this)" readonly />到
<input name="endate" value="2009-08-11" onclick="javascript:ShowCalendar(this)" readonly />
<input type="submit" class="btnsure" value="统计" />
</td>
</tr>
<tr>
<td align="center" colspan="4" height="2px">
<table cellspacing="0" cellpadding="0" width="430px" border="0px">
<tr>
<td align="center" width="30px" height="20px">序号</td>
<td align="center" width="160px" height="20px">时间 </td>
<td align="center" width="80px" height="20px">渠道号</td>
<td align="center" width="80px" height="20px">计费数量</td>
<td align="center" width="80px" height="20px">计费总额</td>
</tr>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mmk";
Connection con=DriverManager.getConnection(url,"sa","sa");
String time1=request.getParameter("stdate");
String time2=request.getParameter("endate");
Statement stmt=con.createStatement();
String sql="select sum(feecount),sum(feeM) from WjHttpData where entime >='"+time1+"'and entime<='"+time2+"'";
ResultSet rs=stmt.executeQuery(sql);
%>
<tr>
<td align="center">合计</td>
<td align="center">null</td>
<td align="center">null </td>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><%=rs.getObject(2) %></td> 这里并不能返回SQL 语句查询的值,不
知道问题出在哪里 了 ?
</tr>
<%
rs.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
errorPage="" %><html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>HttpDate数据统计</title>
<script src="<%=request.getContextPath()%>/tejs.js"></script>
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" method="post" action="test.jsp" >
<table cellspacing="1" cellpadding="3" width="100%" border="0px">
<tr>
<td class="td_title" colspan="4" height="25px">HttpDate数据统计</td>
</tr>
<tr>
<td class="forumRowHighlight" colspan="4" style="height: 24px">统计时间:
<input name="stdate" value="2009-08-01" onclick="javascript:ShowCalendar(this)" readonly />到
<input name="endate" value="2009-08-11" onclick="javascript:ShowCalendar(this)" readonly />
<input type="submit" class="btnsure" value="统计" />
</td>
</tr>
<tr>
<td align="center" colspan="4" height="2px">
<table cellspacing="0" cellpadding="0" width="430px" border="0px">
<tr>
<td align="center" width="30px" height="20px">序号</td>
<td align="center" width="160px" height="20px">时间 </td>
<td align="center" width="80px" height="20px">渠道号</td>
<td align="center" width="80px" height="20px">计费数量</td>
<td align="center" width="80px" height="20px">计费总额</td>
</tr>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mmk";
Connection con=DriverManager.getConnection(url,"sa","sa");
String time1=request.getParameter("stdate");
String time2=request.getParameter("endate");
Statement stmt=con.createStatement();
String sql="select sum(feecount),sum(feeM) from WjHttpData where entime >='"+time1+"'and entime<='"+time2+"'";
ResultSet rs=stmt.executeQuery(sql);
%>
<tr>
<td align="center">合计</td>
<td align="center">null</td>
<td align="center">null </td>
<td align="center"><%=rs.getObject(1) %></td>
<td align="center"><%=rs.getObject(2) %></td> 这里并不能返回SQL 语句查询的值,不
知道问题出在哪里 了 ?
</tr>
<%
rs.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
%>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货