Operation not allowed after ResultSet closed 解决方法
来源:互联网 发布:r语言编程代码 编辑:程序博客网 时间:2024/06/05 06:03
问题出现的原因:
Statement statement = dbConn.createStatement();// 要执行的SQL语句ResultSet rs = statement.executeQuery("select name,salary from workerinfo WHERE salary > 12000");ResultSet rs1 = statement.executeQuery("select name,salary from workerinfo WHERE salary < 12000");while(rs.next()&&rs1.next()){System.out.println( " 工号; " + rs1.getString("salary") +" 姓名:"+ rs1.getString("name"));System.out.println( " 工号; " + rs.getString("salary") +" 姓名:"+ rs.getString("name"));}运行这段代码,会报错:Operation not allowed after ResultSet closed
解决办法:
Statement statement = dbConn.createStatement();// 要执行的SQL语句ResultSet rs = statement.executeQuery("select name,salary from workerinfo WHERE salary > 12000");while(rs.next()){ System.out.println( " 工号; " + rs.getString("salary") +" 姓名:"+ rs.getString("name"));}ResultSet rs1 = statement.executeQuery("select name,salary from workerinfo WHERE salary < 12000");while(rs1.next()){System.out.println( " 工号; " + rs1.getString("salary") +" 姓名:"+ rs1.getString("name")); }结论:一个statment对应多个rs进行操作。从statment得到的rs,必须马上操作此rs后,才能去得到另外的rs1,再对rs1操作,不能互相交替使用,会引起rs已经关闭错误——Operation not allowed after ResultSet closed.
阅读全文
0 0
- Operation not allowed after ResultSet closed 解决方法
- 错误:Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- SQLException: Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- 错误:Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed 解决方案
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed--Mysql
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- error:Operation not allowed after ResultSet closed
- java.sql.SQLException: Operation not allowed after ResultSet closed
- mysql错误:Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed 错误的解决方案
- POJ 2796 Feel Good 笔记
- windows 下安装theano
- JavaScript 模块简史(对象化)
- myql索引
- POJ-1321-棋盘问题
- Operation not allowed after ResultSet closed 解决方法
- 接入金融理财H5活动遇到的问题备忘(防截屏,检查ROOT,金融理财h5安全,混淆不回调)
- NKOJ-1569 骑士共存 <最大独立集><染色法建图>
- 深度优先遍历
- MySQL数据库基础回顾与总结(一)
- [BZOJ2463][中山市选2009]谁能赢呢? ------之 如何写出一份看起来比较短的代码
- datagrid 插件
- 乐视云大前端技术架构
- 手机GPS获取海拔