请教,我的rs.first(),rs.last(),rs,absolute()不能用,rs.getRow()可以用
<body><%
Connection con=conn.getConn();
String sql="select * from liyajieusers";
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
//PreparedStatement ps=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs=stmt.executeQuery(sql);
rs.last();
int rowCount=rs.getRow();
%>
</body>
上面是代码 数据库连接是没有问题的
下面是错误信息
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /3.jsp at line 17
14: Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
15: //PreparedStatement ps=con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
16: ResultSet rs=stmt.executeQuery(sql);
17: rs.last();
18: int rowCount=rs.getRow();
19: %>
20: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp._3_jsp._jspService(_3_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
sun.jdbc.odbc.JdbcOdbcResultSet.last(JdbcOdbcResultSet.java:2291)
org.apache.jsp._3_jsp._jspService(_3_jsp.java:81)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.14 logs.
--------------------编程问答-------------------- result set type is TYPE_FORWARD_ONLY
type设置为TYPE_FORWARD_ONLY 错误
解决方案:type设置CONCUR_UPDATABLE
参考资料:http://hi.baidu.com/bruce42/blog/item/0469710eb45c24c87bcbe19a.html
楼主你在网上没有先查查吗? --------------------编程问答-------------------- ResultSet.CONCUR_READ_ONLY
改成
ResultSet.CONCUR_UPDATABLE --------------------编程问答-------------------- 最好上网查查Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
这里面的各个属性的作用。。 --------------------编程问答-------------------- type设置为TYPE_FORWARD_ONLY 错误
解决方案:type设置CONCUR_UPDATABLE
这样也不行啊,还是会报错 --------------------编程问答-------------------- 我的QQ为 459694700 请求好友加入,远程协助解决,
补充:Java , Web 开发