请教,我的rs.first(),rs.last(),rs,absolute()不能用,rs.getRow()可以用

linyiyazi 2011-11-07 04:20:28
<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.

...全文
318 5 打赏 收藏 举报
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
linyiyazi 2011-11-08
我的QQ为 459694700 请求好友加入,远程协助解决,
  • 打赏
  • 举报
回复
linyiyazi 2011-11-08
type设置为TYPE_FORWARD_ONLY 错误
解决方案:type设置CONCUR_UPDATABLE

这样也不行啊,还是会报错
  • 打赏
  • 举报
回复
kouyiSC 2011-11-07
最好上网查查Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
这里面的各个属性的作用。。
  • 打赏
  • 举报
回复
菖蒲芭芭 2011-11-07
ResultSet.CONCUR_READ_ONLY

改成

ResultSet.CONCUR_UPDATABLE
  • 打赏
  • 举报
回复
shixitong 2011-11-07
result set type is TYPE_FORWARD_ONLY
type设置为TYPE_FORWARD_ONLY 错误
解决方案:type设置CONCUR_UPDATABLE
参考资料:http://hi.baidu.com/bruce42/blog/item/0469710eb45c24c87bcbe19a.html
楼主你在网上没有先查查吗?
  • 打赏
  • 举报
回复
发帖
Web 开发

8.0w+

社区成员

Java Web 开发
社区管理员
  • Web 开发社区
加入社区
帖子事件
创建了帖子
2011-11-07 04:20
社区公告
暂无公告