错误:Operation not allowed after ResultSet closed

??????????????????

一.错误信息

Operation not allowed after ResultSet closed  意为:在结果集关闭不允许操作

二.为什么resultSet会自动关闭

错误关键在于:一个stmt有多个rs进行操作

正确操作应该:从stmt得到的rs1,必须马上操作此rs1后,才能去得到另外的rs2,再对rs2操作.不能互相交替使用;   或者   不用的rs,使用不同的stmt

错误的代码如下:
 stmt=conn.createStatement();
 rs=stmt.executeQuery("select * from t1");
 rst=stmt.executeQuery("select * from t2");
 rs.last();//由于执行了rst=stmt.executeQuery(sql_a);rs就会被关闭掉!所以程序执行到此会提示ResultSet已经关闭。错误信息为:java.sql.SQLException:Operation not allowed after ResultSet closed
 rst.last();

正确的代码:
 stmt=conn.createStatement();
 rs=stmt.executeQuery("select * from t1");
 rs.last();//对rs的操作应马上操作,操作完后再从数据库得到rst,再对rst操作
 rst=stmt.executeQuery("select * from t2");
 rst.last();

??????????????????

时间: 2024-10-25 14:49:56

错误:Operation not allowed after ResultSet closed的相关文章

SQLExecption:Operation not allowed after ResultSet closed解决办法

原网址:http://blog.csdn.net/sku0923/article/details/1722370 一个stmt多个rs进行操作引起的ResultSet已经关闭错误 一个stmt多个rs进行操作. 那么从stmt得到的rs1,必须马上操作此rs1后,才能去得到另外的rs2,再对rs2操作. 不能互相交替使用,会引起rs已经关闭错误. 错误的代码如下:  stmt=conn.createStatement(); rs=stmt.executeQuery("select * from

java.sql.SQLException: Operation not allowed after ResultSet closed

转自:http://blog.csdn.net/hellobobantang/article/details/7173622 java.sql.SQLException: Operation not allowed after ResultSet closedat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)at com.mysql.jdbc.SQLError.createSQLException(SQLError.

Operation not allowed after ResultSet closed

首先应该按照网上搜到的方法检查一下是否是一个statement对多个ResultSet进行操作. 比方说: Statement st = conn.CreateStatement(); ResultSet rs1 = st.executeQuery(); ResultSet rs2 = st.executeQuery(); 则必须先对rs1进行操作,然后再对rs2进行操作,不能交替操作.否则会引起rs已经关闭错误,因为执行第三条语句的时候,程序默认将rs2关闭,再对rs2进行操作的时候,就会发生

Operation not allowed on a unidirectional dataset错误?

关于网友提出的“ Operation not allowed on a unidirectional dataset错误?”问题疑问,本网通过在网上对“ Operation not allowed on a unidirectional dataset错误?”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下: 问题: Operation not allowed on a unidirectional dataset错误?描述: 我在使用TSQLQuery组件查询Oracle数据库中的表

记weblogic JDBC 'No operations allowed after statement closed' 缘由

平台应用开发人员向我们平台报了一个issue,说在测试他们应用的时候遇到一个奇怪的问题,系统报了undefinedexception(开发人员自定义的exception,捕捉了jpa exception之后发现无法处理的情况下就抛出未定义异常),他们贴出了weblogic里面报出的异常栈信息: <Sep 17, 2014 7:56:45 AM SAST> <Error> <org.hibernate.transaction.JDBCTransaction> <BE

db2报错 Operation not allowed for reason

1.DB2数据库表操作错误SQL0668N Operation not allowed for reason code "1" on table "XXXX". SQLSTATE=57016的解决方法 The table is in Check Pending state. The integrity of the table is not enforced and the content of the table may be invalid. An operat

ORA-10618: Operation not allowed on this segment

执行SHOW_SPACE存储过程时只能在DBA角色下成功,在NORMAL角色用户下报错: ORA-10618: Operation not allowed on this segmentORA-06512: at "SYS.DBMS_SPACE", line 167ORA-06512: at "DMS.SHOW_SPACE", line 65ORA-06512: at line 2 遇到ORA -error 第一件要做的事情就是查看 "error mess

myBatis连接MySQL报异常:No operations allowed after connection closed.Connection was implicitly closed

网站运行一个晚上,早上来上班,发现报错: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed. 网上查了下,由于使用了默认配置,空闲超过8小时,自动断开该连接 我使用的是mybatis的默认连接池,于是把该配的,都配置上.datasource的属性

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.

ERROR - No operations allowed after connection closed. org.hibernate.exception.JDBCConnectionException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74) at org.hibernate.exception.JDBCExceptionHe