SQLServerException: 只进结果集不支持请求的操作

com.microsoft.sqlserver.jdbc.SQLServerException:只进结果集不支持请求的操作。atcom.microsoft.sqlserv... com.microsoft.sqlserver.jdbc.SQLServerException: 只进结果集不支持请求的操作。
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.throwNotScrollable(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.verifyResultSetIsScrollable(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.beforeFirst(Unknown Source)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:283)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.NetworkShop.SelectProduct.doPost(SelectProduct.java:51)
at com.NetworkShop.SelectProduct.doGet(SelectProduct.java:42)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527)
at java.lang.Thread.run(Thread.java:619)
出现这样的错误,数据库连接正确,是另外的一个类,ResultSet已经取到值,request.setAttribute("SelectPro",rs ); request.getRequestDispatcher("index.jsp").forward(request, response);在jsp页面中用getAttribute取
jsp中代码
int pnum = 0;
int a = 0;
try{
ResultSet rs = (ResultSet)request.getAttribute("SelectPro");
while(rs.next()){
pnum++; }
String number = String.valueOf(pnum);
HttpSession sess = request.getSession();
sess.setAttribute("number", number);
rs.beforeFirst();
while(rs.next()){
int pCode = rs.getInt(1);
String pName = rs.getString(2);
double price = rs.getDouble(3);
int quantity = rs.getInt(4);}
在Servlet中doPost(SelectProduct.java:51)是.getRequestDispatcher("index.jsp").forward(request, response)这行。以前是用Access数据库,现在改用sql server,数据都能取出。
展开
 我来答
PPoS丨丶灬疯杰
2010-05-07 · TA获得超过835个赞
知道小有建树答主
回答量:494
采纳率:0%
帮助的人:530万
展开全部
不知道是哪行的问题
可能是这个结果集是只能迭代一次的 不能用rs.beforeFirst()这个方法
也就是程序说的只进
你可以创建一个滚动的结果集 把之前某行换成
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE)

我也是猜的 可以试一下~
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式