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

//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>

你可能感兴趣的:(java,oracle,sql,jsp,mobile)