问题描述
只要我的代码进入我的 while(rs.next())
循环,它就会产生 ResultSet
is closed 异常.是什么导致了这个异常,我该如何纠正它?
As soon as my code gets to my while(rs.next())
loop it produces the ResultSet
is closed exception. What causes this exception and how can I correct for it?
我注意到在我的代码中我将 while(rs.next())
循环与另一个 (rs2.next())
,两个结果集来自同一个数据库,这是一个问题吗?
I notice in my code that I am nesting while(rs.next())
loop with another (rs2.next())
, both result sets coming from the same DB, is this an issue?
推荐答案
听起来您在遍历第一个语句的结果集之前在同一个连接中执行了另一个语句.如果您嵌套处理来自同一个数据库的两个结果集,那么您做错了.这些集合的组合应该在数据库端完成.
Sounds like you executed another statement in the same connection before traversing the result set from the first statement. If you're nesting the processing of two result sets from the same database, you're doing something wrong. The combination of those sets should be done on the database side.
这篇关于如何避免 ResultSet 是 Java 中的关闭异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!