“光标关闭”错误 - 尝试使用JDBC执行Oracle SP时 [英] "Cursor is closed" error - when trying to execute an Oracle SP using JDBC
问题描述
我们的数据库的Oracle版本是10g。
The Oracle version of our database is 10g.
存储过程选择表中的所有元素,并返回REF CURSOR类型,如下所示:
创建或替换
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;
在JAVA中执行此存储过程时,会获得以下异常 -
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?
谢谢!
推荐答案
客户端调用存储过程负责关闭游标。请删除代码:
CLOSE test_OUT;
The client calling the stored procedure is responsible for closing the cursor. Please remove the code: CLOSE test_OUT;
客户端关闭它。在这种情况下,客户端是调用存储过程的JDBC程序。
The client closes it. In this case the client is the JDBC program that calls the stored procedure.
这篇关于“光标关闭”错误 - 尝试使用JDBC执行Oracle SP时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!