分页操作时出现javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态

jiangcui2003 2008-12-18 09:42:43
我时新手
请问哪为专家能给解答一下 在线等 谢谢
源代码我贴在下面了
...全文
201 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lyf_sust 2008-12-25
  • 打赏
  • 举报
回复
rs1.next();
next的次数会不会有问题
jiangcui2003 2008-12-19
  • 打赏
  • 举报
回复
等待中>>>>>>>>>>>>>>>>
jiangcui2003 2008-12-18
  • 打赏
  • 举报
回复
错误提示
exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /teacher/kaoshi/xzt.jsp at line 63

60: rs1.next();
61: n++;
62: i++;
63: id=rs1.getInt("ID");
64: timu=rs1.getString("question");
65:
66: %>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
org.apache.jsp.teacher.kaoshi.xzt_jsp._jspService(xzt_jsp.java:231)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root cause

java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
org.apache.jsp.teacher.kaoshi.xzt_jsp._jspService(xzt_jsp.java:130)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.10
jiangcui2003 2008-12-18
  • 打赏
  • 举报
回复
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>浏览试卷</title>
</head>

<body>
<jsp:useBean id="connect" class="mybean.Connect" scope="page">
</jsp:useBean>
<div align="left">以下是本门课程的所有单项选择题,请添加组成试卷:
<a href="llsj.jsp">返回</a></div>
<hr align="left" />
<div align="left">
<%
String coursename=(String)session.getAttribute("coursename");
if(coursename==null)
response.sendRedirect("../../index.jsp");
String name=(String)session.getAttribute("name");
%>
<%
String sql1="select * from qmxzt where name='"+coursename+"'and type='选择题'";
Statement stmt1=connect.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=connect.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs1=null;
String timu=null;
rs1=stmt1.executeQuery(sql1);
String sqlcount="select count(*) from qmxzt where name='"+coursename+"'and type='选择题'";
ResultSet rscount=stmtcount.executeQuery(sqlcount);
int pageSize=5;
int rowCount=0; //总的记录数
while (rscount.next()){
rowCount=rscount.getInt(1);
}
int pageCount; //总的页数
int currPage; //当前页数
String strPage;
strPage=request.getParameter("page");
if (strPage==null){
currPage=1;
}
else{
currPage=Integer.parseInt(strPage);
if (currPage<1) currPage=1;
}
pageCount=(rowCount+pageSize-1)/pageSize;
if (currPage>pageCount) currPage=pageCount;
int thepage=(currPage-1)*pageSize;
int n=0;
rs1.absolute(thepage+1);
int i=0;
int id=0;
%>
<strong>(一)单项选择题:</strong>
<table width="636" height="62" border="1" align="left" cellspacing="3">
<%
while(n<(pageSize)&&!rs1.isAfterLast())
{
rs1.next();
n++;
i++;
id=rs1.getInt("ID");
timu=rs1.getString("question");

%>
<tr><td width="533" height="28"><%=i%> <%=timu%>  </td>
<td width="87"><a href="zj.jsp?id=<%=id%>">选择为试题</a></td>
</tr>

<% }
%>
<tr>
<td height="23" colspan="2"><form name="sinfo" method="post" action="xzt.jsp?type='选择题'" onSubmit="return testform(this)">
<p>第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条

<%if(currPage>1){%>
<a href="xzt.jsp?xzt.jsp?type='选择题'">首页</a>
<%}%>

<%if(currPage>1){%>
<a href="xzt.jsp?page=<%=currPage-1%>&type='选择题'">上一页</a>
<%}%>

<%if(currPage<pageCount){%>
<a href="xzt.jsp?page=<%=currPage+1%>&type='选择题'">下一页</a>
<%}%>

<%if(pageCount>1){%>
<a href="xzt.jsp?page=<%=pageCount%>&type='选择题'">尾页</a>
<%}%>

跳到
<input type="text" name="page" size="4" style="font-size:9px">


<input type="submit" name="submit" size="4" value="GO" style="font-size:9px">
</p>
</form> </td>
</tr>
</table>
<p> </p>

<p> </p>
<p>  </p>
<p> </p>
</body>
<%
rs1.close();
rs1=null;
stmt1.close();
stmt1=null;
rscount.close();
rscount=null;
stmtcount.close();
stmtcount=null;
connect.closed();

%>
</html>

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧