String time="m"+String.valueOf(month)+"d"+String.valueOf(day);
sql="insert into counte(date,today,first,secon,third,forth,fifth,sixth) values('time',0,0,0,0,0,0,0)";
smt.executeUpdate(sql);这里面date为字符型,而其它字段均为整型。为什么测试时通过,而在运行程序时总提示insert into 语句有错误呢?
解决方案 »
- java打开中文名附件就报错(没法识别中文字符)
- javascript实现刷新浏览器(按F5),页面某处,假设是一个div,div中的内容就发生变化
- 一个OA系统的登陆问题
- c3p0的最大空闲时间为什么不起作用
- jsp页面嵌入word 区域
- jsp制作批量下载
- 在网上看到作SQL Server连接池需要用jtds.jar,请有的高手们给小弟传一个,或告诉个下载的网址,谢谢!
- response.sendRedirect()简单问题,送分了
- 哪里有Tomcat下载,给个链接吧,谢谢了
- Resin给我一个难题。该如何解决?
- MyEclipse Tomcat 问题 谢谢各位大侠了
- 这样连接SQL2000为什么不能执行最后的 insert操作?
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="java.sql.ResultSet"%>
<%@include file="opendata.jsp"%>
<%
request.getSession(true);
int month,day,hour,today,total,select;
String time;
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 counte where date='time'";
rs=smt.executeQuery(sql);
if(!rs.next())
{
sql="insert into counte(date,today,first,secon,third,forth,fifth,sixth) values('time',0,0,0,0,0,0,0)";
smt.executeUpdate(sql);
}
sql="select * from counte where date='time'";
rs=smt.executeQuery(sql);
today=rs.getInt(2);
select=(int)Math.floor(hour/4)+1;
sql="select * from total";
rs=smt.executeQuery(sql);
total=rs.getInt(1);
if(session.isNew())
{
today++;
switch(select)
{
case 1:sql="update counte set today=today,first=first+1 where date='time'";
smt.executeUpdate(sql);
break;
case 2:sql="update counte set today=today,secon=secon+1 where date='time'";
smt.executeUpdate(sql);
break;
case 3:sql="update counte set today=today,third=third+1 where date='time'";
smt.executeUpdate(sql);
break;
case 4:sql="update counte set today=today,forth=forth+1 where date='time'";
smt.executeUpdate(sql);
break;
case 5:sql="update counte set today=today,fifth=fifth+1 where date='time'";
smt.executeUpdate(sql);
break;
case 6:sql="update counte set today=today,sixtht=sixth+1 where date='time'";
smt.executeUpdate(sql);
}
total++;
sql="update total set total=total+1";
smt.executeUpdate(sql);
smt.close();
conn.close();
}
%>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人数浏览统计</title>
<p align=center><img src="1.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>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option></select>月</td>
<td><selcet size=1 name=day>
<option selected>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option><option>7</option><option>8</option><option>9</option>
<option>10</option><option>11</option><option>12</option><option>13</option>
<option>14</option><option>15</option><option>16</option><option>17</option><option>18</option><option>19</option>
<option>20</option><option>21</option><option>22</option><option>23</option><option>24</option><option>25</option><option>26</option>
<option>27</option><option>28</option><option>29</option><option>30</option><option>31</option></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>
rs=smt.executeQuery(sql);
today=rs.getInt(2);在today=rs.getInt(2);之前应再调用一次
rs.next();
这个rs已经不是原来的rs了。
today=rs.getInt(2);
select=(int)Math.floor(hour/4)+1;
sql="select * from total";
rs=smt.executeQuery(sql);
total=rs.getInt(1);
后,rs就不是原来的rs啦,继续在total=rs.getInt(1);前
加上rs.next()了.....
凡是遇到这种情况你就next一下好了......
rs=smt.executeQuery(sql);
today=rs.getInt(2);
select=(int)Math.floor(hour/4)+1;
sql="select * from total";
rs=smt.executeQuery(sql);
total=rs.getInt(1);
查完后加一个rs.next90
他就象链表一样,头是空的只是一个入口