“光标已关闭” 错误 - 尝试使用 JDBC 执行 Oracle SP 时
我们数据库的Oracle版本是10g。
该存储过程选择表中的所有元素并返回 REF CURSOR 类型,如下所示: 创建或替换
PROCEDURE S_S_TEST(
test_OUT OUT OAS_TYPES.REFCURSOR
)
AS
BEGIN
OPEN test_OUT FOR
SELECT *
FROM table_p;
CLOSE test_OUT;
END S_S_TEST;
当在 JAVA 中执行此存储过程时,会出现以下异常 -
java.sql.SQLException: Cursor is closed. at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:323) at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:85) at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401) at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.getObject(WSJdbcCallableStatement.java:443)
我试图了解错误是什么以及如何修复它。 有人可以帮我吗?
谢谢!
The Oracle version of our database is 10g.
The stored procedure selects all the elements in a table and returns a REF CURSOR type as follows:
create or replace
PROCEDURE S_S_TEST(
test_OUT OUT OAS_TYPES.REFCURSOR
)
AS
BEGIN
OPEN test_OUT FOR
SELECT *
FROM table_p;
CLOSE test_OUT;
END S_S_TEST;
When this stored procedure is executed in JAVA the following exception is obtained-
java.sql.SQLException: Cursor is closed. at oracle.jdbc.driver.T4CResultSetAccessor.getCursor(T4CResultSetAccessor.java:323) at oracle.jdbc.driver.ResultSetAccessor.getObject(ResultSetAccessor.java:85) at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1401) at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.getObject(WSJdbcCallableStatement.java:443)
I am trying to understand what the error is and how it could be fixed. Could someone please help me out?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
调用存储过程的客户端负责关闭游标。 请删除代码:
关闭测试_输出;
客户端关闭它。 在本例中,客户端是调用存储过程的 JDBC 程序。
The client calling the stored procedure is responsible for closing the cursor. Please remove the code:
CLOSE test_OUT;
The client closes it. In this case the client is the JDBC program that calls the stored procedure.