java.sql.SQLException:无效状态,ResultSet 对象已关闭

发布于 2024-10-15 07:13:35 字数 1255 浏览 5 评论 0原文

我正在尝试使用 jtds 运行 StoredProcedure。 我的数据库位于 SQL SErver 2008 上,

private String DRIVER_NAME_VALUE = "net.sourceforge.jtds.jdbc.Driver";  
private String URL_VALUE = "jdbc:jtds:sqlserver://"; 
...
cstmt =dbConnection.getCallableStatement("{? = call dbo.GetAgentStats (?)}");
.
.
.
rs = cstmt.executeQuery();

当尝试检查结果集时,我收到异常:

java.sql.SQLException: Invalid state, the ResultSet object is closed.
        at net.sourceforge.jtds.jdbc.JtdsResultSet.checkOpen(JtdsResultSet.java:299)
        at net.sourceforge.jtds.jdbc.JtdsResultSet.first(JtdsResultSet.java:527)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.runReport(CCEASCMAdapter.java:238)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.retrieveData(CCEASCMAdapter.java:131)
        at com.bluepumpkin.Plugins.PTeXtender.GenericDCSPlugin.retrieveStatisticsData(GenericDCSPlugin.java:332)
        at com.bluepumpkin.Plugins.PTeXtender.GenericDCSPlugin.start(GenericDCSPlugin.java:68)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.main(CCEASCMAdapter.java:75)
Logger.logStackTrace():----- End Stack Trace   ------

它与 SQL Server 2008 有关吗? 我不确定,但我在连接到 SQL Server 2005 时没有出现此错误。

谢谢

I am trying to run StoredProcedure using jtds.
My database is on SQL SErver 2008

private String DRIVER_NAME_VALUE = "net.sourceforge.jtds.jdbc.Driver";  
private String URL_VALUE = "jdbc:jtds:sqlserver://"; 
...
cstmt =dbConnection.getCallableStatement("{? = call dbo.GetAgentStats (?)}");
.
.
.
rs = cstmt.executeQuery();

when trying to go over the Result set I got the Exception:

java.sql.SQLException: Invalid state, the ResultSet object is closed.
        at net.sourceforge.jtds.jdbc.JtdsResultSet.checkOpen(JtdsResultSet.java:299)
        at net.sourceforge.jtds.jdbc.JtdsResultSet.first(JtdsResultSet.java:527)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.runReport(CCEASCMAdapter.java:238)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.retrieveData(CCEASCMAdapter.java:131)
        at com.bluepumpkin.Plugins.PTeXtender.GenericDCSPlugin.retrieveStatisticsData(GenericDCSPlugin.java:332)
        at com.bluepumpkin.Plugins.PTeXtender.GenericDCSPlugin.start(GenericDCSPlugin.java:68)
        at com.verint.impact360.WFM_plugins.CCE.CCEASCMAdapter.main(CCEASCMAdapter.java:75)
Logger.logStackTrace():----- End Stack Trace   ------

Is it related to SQL Server 2008?
I am not sure ,but I didn't have this error when connectig to SQL Server 2005.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

燃情 2024-10-22 07:13:35

仅当 ResultSet 尚未通过在 ResultSetStatement 上调用 close() 来关闭时,才能对其进行迭代> 和/或连接

如果您的实际意图是将 ResultSet 的内容传递到创建它的方法的范围之外,那么您应该将其映射到 List 首先然后返回它。或者,如果您的实际意图是将其传递给需要 ResultSet 作为参数的其他类/方法(这本身就是一个糟糕的设计,但除此之外),那么您应该在内部执行此操作创建了与 ResultSet 完全相同的 try 块。

You can only iterate over the ResultSet when it has not already been closed by calling close() on ResultSet, Statement and/or Connection.

If your actual intent is to pass the content of the ResultSet out of the scope of the method where it is been created, then you should be mapping this to a List<SomeObject> first and then return it instead. Or if your actual intent is to pass it to some other class/method which expects a ResultSet as argument (which is by its own a poor design, but that aside), then you should be doing that inside the very same try block as the ResultSet is been created.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文