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 中的关闭异常?


- 如何使用WebFilter实现授权头检查 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01