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,数据都能取出。 展开
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,数据都能取出。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询