Topic: SQLServer 2000:Invalid operation for the current cursor position

  Print this page

1.SQLServer 2000:Invalid operation for the current cursor position Copy to clipboard
Posted by: haiming
Posted on: 2005-10-19 18:05

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@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 counter where date='"+time+"'";
rs=stmt.executeQuery(sql);
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=stmt.executeQuery(sql);
}
sql="select*from counter where date='"+time+"'";
rs=stmt.executeQuery(sql);
today=rs.getInt(2);
select=(int)Math.floor(hour/4)+1;
sql="select*from total";
rs=stmt.executeQuery(sql);
total=rs.getInt(1);
if(session.isNew())
{
today++;
switch(select)
{
case 1:sql="update counter set today="+today+",first=first+1 where date='"+time+"'";
stmt.executeQuery(sql);
break;
case 2:sql="update counter set today="+today+",secon=secon+1 where date='"+time+"'";
stmt.executeQuery(sql);
break;
case 3:sql="update counter set today="+today+",third=third+1 where date='"+time+"'";
stmt.executeQuery(sql);
break;
case 4:sql="update counter set today="+today+",forth=forth+1 where date='"+time+"'";
stmt.executeQuery(sql);
break;
case 5:sql="update counter set today="+today+",fifth=fifth+1 where date='"+time+"'";
stmt.executeQuery(sql);
break;
case 6:sql="update counter set today="+today+",sixth=sixth+1 where date='"+time+"'";
stmt.executeQuery(sql);

}
total++;
sql="update total set total=total+1";
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
%>
错误:
javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC]Invalid operation for the current cursor position.
  org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
  org.apache.jsp.count_jsp._jspService(count_jsp.java:180)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

2.Re:SQLServer 2000:Invalid operation for the current cursor position [Re: haiming] Copy to clipboard
Posted by: chengbd
Posted on: 2005-10-20 23:14

SQLServer 2000 Driver 的JDBC,为了避免出错,字段在读取时,要按select的顺序来,而且最好只用“向前”的游标,这是原则。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923