How can I avoid ResultSet is closed exception in Java?(如何避免 ResultSet 是 Java 中的关闭异常?)
问题描述
只要我的代码进入我的 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 中的关闭异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何避免 ResultSet 是 Java 中的关闭异常?


基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- Java Swing计时器未清除 2022-01-01