统计一天的访问人数以及总访问数

//index.jsp

<%@ include file="inc/head.jsp"%>
<%@ page language="java"
import="java.sql.*,java.util.*,com.zj.comm.util.Common"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<wml>
<head>
</head>
<card id="signup" title="中国丰动">

<p>
<%
Connection conn = null;
PreparedStatement ps = null;
PreparedStatement psl = null;
ResultSet rs = null;
ResultSet rsl = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
conn = DriverManager.getConnection(
"jdbc:oracle:thin://localhost:1521:orcl", "zhang",
"zhang");
String sql = "select count(id) from (select * from (select * from temporary where trunc(createtime)=trunc(sysdate)) order by createtime desc)";
ps = conn.prepareStatement(sql);
String sqll = "select count(id) from temporary";
psl = conn.prepareStatement(sqll);
ps.executeUpdate();
psl.executeUpdate();
rs = ps.executeQuery();
rsl = psl.executeQuery();

while (rs != null && rs.next()) {
%>
今日签到:<%=rs.getInt(1)%>

<%
}
while (rsl != null && rsl.next()) {
%>
总签到:<%=rsl.getInt(1)%>

<%
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
}
if (rsl != null) {
rsl.close();
}
if (ps != null) {
ps.close();
}
if (psl != null) {
psl.close();
}
if (conn != null) {
rsl.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
%>
<br />
春天来了,幸运的用户们快来掌上
<br />
丰动吧,等待你们的加入,同时也为大
<br />
家准备了丰盛的话费奖励!
<br />
<img src="images/huodongduixiang.jpg" />
<br />
中国丰动幸运用户
<br />
<img src="images/huodongshijian.jpg"></img>
<br />
3月25号-4月25号
<br />
<img src="images/huodonguize.jpg"></img>
<br />
活动期间,只要您是中国丰动的幸
<br />
运用户,在不同的2天,点击“签到”
<br />
按钮,就可以获得3元话费奖励,话费
<br />
将于下月统一返充到您的账户!
<br />
<a href="get.jsp"><img src="images/qiandao.jpg"></img>
</a>
<br />
</p>
<%@ include file="inc/bottom.jsp"%>
</card>
</wml>



//get.jsp

<%@ include file="inc/head.jsp" %>
<%@ page language="java" import="java.sql.*,java.util.*,com.zj.comm.util.Common" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<wml>
<head>
</head>
<card id="signup" title="中国丰动">

<p>

<%
String mobile = Common.getMobile(request);

if ("".equals(mobile) || mobile == null) {
out.print("非手机用户,请您使用手机上网");
out.print("<br/>");
out.print("非法上网用户,请您准找有关法律正常上网");
out.print("<br/>");
} else {
try {
Connection conn = null;
PreparedStatement ps = null;
PreparedStatement psl = null;
ResultSet rs = null;
Class.forName("oracle.jdbc.driver.OracleDriver")
.newInstance();
conn = DriverManager.getConnection("jdbc:oracle:thin://localhost:1521:orcl","zhang","zhang");
String sql = "insert into temporary (id) values ('"
+ mobile + "')";
ps = conn.prepareStatement(sql);
String sqll="update temporary set today=1 where id='"+mobile+"'";
psl = conn.prepareStatement(sqll);
ps.executeUpdate();
psl.executeUpdate();
response.sendRedirect("index.jsp");
} catch (Exception e) {
e.printStackTrace();
}
}
%>

</p>
<%@ include file="inc/bottom.jsp" %>
</card>
</wml>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值