请教,我的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.

...全文
353 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
楼主你在网上没有先查查吗?

81,089

社区成员

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

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