Operationnot allowed after ResultSetclosed
来源:互联网 发布:mac语言切换 编辑:程序博客网 时间:2024/06/07 00:59
一个stmt多个rs进行操作引起的ResultSet已经关闭错误
一个stmt多个rs进行操作.
那么从stmt得到的rs1,必须马上操作此rs1后,才能去得到另外的rs2,再对rs2操作.
不能互相交替使用,会引起rs已经关闭错误.
错误的代码如下:
正确的代码:
原因是:
一个stmt最好对应一个rs, 如果用一个时间内用一个stmt打开两个rs同时操作,会出现这种情况.
所以解决此类问题:1.就多创建几个stmt,一个stmt对应一个rs;2.若用一个stmt对应多个rs的话,那只能得到一个rs后就操作,处理完第一个rs后再处理其他的,如上"正确代码".
多个stmt对应各自的rs.
stmt=conn.createStatement();
stmt2=conn.createStatement();
rs=stmt.executeQuery("select * from t1");
rst=stmt2.executeQuery("select * from t2");
rs.last();
rst.last();
转于:http://blog.csdn.net/sku0923/article/details/1722370
- Operationnot allowed after ResultSetclosed
- 错误:Operation not allowed after ResultSet closed
- No operations allowed after connection closed 错误
- Operation not allowed after ResultSet closed
- SQLException: Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- solr no operations allowed after connection closed
- No operations allowed after connection closed
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- 错误:Operation not allowed after ResultSet closed
- MySQLNonTransientConnectionException: No operations allowed after statement closed
- Operation not allowed after ResultSet closed 解决方案
- Operation not allowed after ResultSet closed
- Operation not allowed after ResultSet closed
- No operations allowed after statement closed.
- Struts.......No operations allowed after connection closed.
- Operation not allowed after ResultSet closed--Mysql
- Ajax基础(检查用户名是否存在)
- Oracle 在SQL*Plus中如何显示当前…
- JDBC连接到MySQL和oracle
- java环境变量配置
- [自学问题总结]StringBuilder 和 String 的区别
- Operationnot allowed after ResultSetclosed
- (转)MySQL 查看约束,添加约束,删…
- (转)Struts1和Struts2的区别和对比…
- org.hibernate.MappingException: …
- JSP中include指令和include行为区…
- 用java的i/o读写文件,举一反三看…
- Myeclipse10下载,安装,破解,插件,…
- 进程和线程的区别与联系--精
- 设计模式之策略模式(Duck设计模式)