如何避免ResultSet是Java中的封闭异常? [英] How can I avoid ResultSet is closed exception in Java?

查看:86
本文介绍了如何避免ResultSet是Java中的封闭异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我的代码进入我的 while(rs.next())循环,它会生成 ResultSet 是封闭的例外。什么原因导致这个例外,我该如何纠正?

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中的封闭异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆