| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 171 人关注过本帖
标题:[求助]jsp一个计数器程序是从书上拷来的不能运行
取消只看楼主 加入收藏
eagle_chen88
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-10-29
收藏
 问题点数:0 回复次数:0 
[求助]jsp一个计数器程序是从书上拷来的不能运行

你好我这个程序是在学一本书时的一个例子,可是怎么也不能运行..总是那个代码说"类型不匹配"
大哥们帮一帮吧.我是小鸟...
opendata.jsp_____________
<%
Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql://localhost:3306/mydata";
Connection con=DriverManager.getConnection(url,"root","123");
Statement smt=con.createStatement();
ResultSet rs;
//int rs;

%>

counte.jsp_________________________________
<%@ page import ="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ include file="opendata.jsp"%>
<%@ page contentType="text/html;charset=GB2312"%>
<%
request.getSession(true);
int month,day,hour,today,total,select;
String time;
int sql;

String errmsg=request.getParameter("errmsg");
GregorianCalendar calendar;
calendar=new GregorianCalendar();
month=calendar.get(Calendar.MONTH)+1;
day=calendar.get(Calendar.DAY_OF_MONTH);
hour=calendar.get(Calendar.HOUR_OF_DAY);
time="m"+String.valueOf(month)+"d"+String.valueOf(day);
//sql="select * from counter where date='"+time+"'";
rs=smt.executeQuery("select * from counter where date='"+time+"'");
if(!rs.next());
{
sql="insert into counter(date,today,first,secon,third,forth,fifth,sixth) values('"+time+"',0,0,0,0,0,0,0)";
rs=smt.executeUpdate(sql);
}
//sql="select * from counter where date='"+time+"'";
rs=smt.executeQuery("select * from counter where date='"+time+"'");
today=rs.getInt(2);
out.print(today);
out.close();
select=(int)Math.floor(hour/4)+1;
//sql="select * from total";
rs=smt.executeQuery("select * from total");
total=rs.getInt(1);
if(session.isNew())
{
today++;
switch(select)
{
case 1: //sql="update counter set today="+today+",first=first+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",first=first+1 where date='"+time+"'");
break;
case 2: //sql="update counter set today="+today+",secon=secon+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",secon=secon+1 where date='"+time+"'");
break;
case 3: //sql="update counter set today="+today+",third=third+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",third=third+1 where date='"+time+"'");
break;
case 4: //sql="update counter set today="+today+",forth=forth+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",forth=forth+1 where date='"+time+"'");
break;
case 5: //sql="update counter set today="+today+",fifth=fifth+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",fifth=fifth+1 where date='"+time+"'");
break;
case 6: //sql="update counter set today="+today+",sixth=sixth+1 where date='"+time+"'";
smt.executeQuery("update counter set today="+today+",sixth=sixth+1 where date='"+time+"'");
break;
}
total++;
//sql="update total set total=total+1";
smt.executeQuery("update total set total=total+1");
smt.close();
con.close();
}
%>
<html>
<title>人数浏览统计</title>
<p align-center><img src=zct.jpg><br>
<%
String showcount=String.valueOf(total);
out.print("您是本站的第");
for(int i=0;i<showcount.length();i++)
out.print("<img src="+showcount.charAt(i)+".jpg>");
out.print("位上网使用者<br>");
showcount=String.valueOf(today);
out.print("您是今天的第");
for(int i=0;i<showcount.length();i++)
out.print("<img src="+showcount.charAt(i)+".jpg>");
out.print("位上网使用者");
%>
<hr>
<center>
<form action-search.jsp method=post>
<table border=0>
<tr>
<td><font color=green>查询上网人数统计:<font></td>
<td><select size=1 name=month>
<option selected>1<option>2<option>3<option>4<option>5<option>
<option>6<option>7<option>8<option>9<option>10<option>11<option>12
</select>月
</td>
<td><select size=1 name=day>
<option selected>1<option>2<option>3<option>4<option>5<option>
<option>6<option>7<option>8<option>9<option>10<option>11<option>12
<option>13<option>14<option>15<option>16<option>17<option>
<option>18<option>19<option>20<option>21<option>22<option>23<option>24
<option>25<option>26<option>27<option>28<option>29<option>
<option>30<option>31
</select> 日
</td>
<td><input type=submit name=send value=查询></td>
</tr>
<tr>
<td colspan=4 align=center>
<a href=search.jsp?month=<%=month%>&day=<%=day%>>
<font size=3>查看今日稳中有降时段流量统计</font></a></td>
</tr>
</table>
</form>
<font color=red size=4>
<%
if(errmsg!=null)
out.print(errmsg);
%>
</font>
</html>
表结构
CREATE TABLE `counter` (
`date` char(6) DEFAULT NULL,
`today` int(6) DEFAULT NULL,
`first` int(6) DEFAULT NULL,
`secon` int(6) DEFAULT NULL,
`third` int(6) DEFAULT NULL,
`forth` int(6) DEFAULT NULL,
`fifth` int(6) DEFAULT NULL,
`sixth` int(6) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;

CREATE TABLE `total` (
`total` int(6) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gb2312;
哪位大哥帮一帮..小弟谢谢了.


[此贴子已经被作者于2007-10-29 16:36:54编辑过]

2007-10-29 16:30
快速回复:[求助]jsp一个计数器程序是从书上拷来的不能运行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025595 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved