Operation not allowed for a result set of type ResultSet的bug

weixin_46796279 2020-05-22 01:09:10
java中Operation not allowed for a result set of type ResultSet要怎么解决啊啊啊啊啊啊啊
...全文
2718 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_43922513 2021-05-10
  • 打赏
  • 举报
回复
connect=dataSource.getConnection(); Statement stmt=connect.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,                         ResultSet.CONCUR_UPDATABLE);
Linux-wind 2021-05-10
  • 打赏
  • 举报
回复
知道错误原因了。 因为当前位置已经是last了,last就不能用了。
Linux-wind 2021-05-10
  • 打赏
  • 举报
回复
rs.last()就是81行 报错 java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.
Linux-wind 2021-04-16
  • 打赏
  • 举报
回复
我的也是同样的报错 public void getData() throws ClassNotFoundException, SQLException { ResultSet rs = conn.createStatement().executeQuery("select * from t_article"); //try{rs.last();}catch(SQLException e){System.out.println("int:"+rs.getRow()+" "+e.toString());}; //移到最后一行 rs.last(); if(rs.getRow()>0) { //获取当前rs位置(获取记录数量) rs.beforeFirst(); //移到初始位置 while(rs.next()) { System.out.println( rs.getInt(1)+ " " + rs.getString(2) + " " + rs.getString(3) + " " + rs.getString(4) + " " + rs.getDate(5)); } }else { System.out.println("没有数据"); } rs.close(); } ----------------------------------------------------OUTPUT--------------------------------------------------------- Exception in thread "main" java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.result.ResultSetImpl.last(ResultSetImpl.java:1729) at SQLData.resultset(SQLData.java:85) at SQLData.getData(SQLData.java:81) at SQLData.main(SQLData.java:19) Process finished with exit code 1
luckyZQC 2020-05-22
  • 打赏
  • 举报
回复
一个conn对应一个st对应一个rs
luckyZQC 2020-05-22
  • 打赏
  • 举报
回复
代码贴出来

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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