java.sql.SQLException:无效状态,ResultSet 对象已关闭
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当
ResultSet
尚未通过在ResultSet
、Statement
上调用close()
来关闭时,才能对其进行迭代> 和/或连接
。如果您的实际意图是将
ResultSet
的内容传递到创建它的方法的范围之外,那么您应该将其映射到List
首先然后返回它。或者,如果您的实际意图是将其传递给需要ResultSet
作为参数的其他类/方法(这本身就是一个糟糕的设计,但除此之外),那么您应该在内部执行此操作创建了与ResultSet
完全相同的try
块。You can only iterate over the
ResultSet
when it has not already been closed by callingclose()
onResultSet
,Statement
and/orConnection
.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 aList<SomeObject>
first and then return it instead. Or if your actual intent is to pass it to some other class/method which expects aResultSet
as argument (which is by its own a poor design, but that aside), then you should be doing that inside the very sametry
block as theResultSet
is been created.