My Oracle Support Banner

Java.Sql.Sqlexception: Closed Statement: Next When Using Ref Cursor (Doc ID 1274294.1)

Last updated on SEPTEMBER 26, 2019

Applies to:

SQLJ - Version 11.1.0.6 and later
Information in this document applies to any platform.

Symptoms

SQLJ wrapper created for a PL/SQL procedure that returns REF CURSOR, fails with following at run time.

Exception in thread "main" java.sql.SQLException: Closed Statement: next
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.OracleResultSetImpl.next(OracleResultSetImpl.java:187)
at sqlj.runtime.ref.OraRTResultSet.next(OraRTResultSet.java:121)
at sqlj.runtime.ref.ResultSetIterImpl.next(ResultSetIterImpl.java:211)
at Main.main(Main.java:90)


SQLJ translates it to the following kind of code :-

try {
String theSqlTS = "BEGIN :1 := sqlj_refcursor.job_listing('SALES') \n; END;";
__sJT_st = __sJT_ec.prepareOracleCall(__sJT_cc,"0Main",theSqlTS);
if (__sJT_ec.isNew())
{
__sJT_st.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR);
}
// execute statement
__sJT_ec.oracleExecuteUpdate();
// retrieve OUT parameters
iter = new Main.EmpIter(new sqlj.runtime.ref.OraRTResultSet(__sJT_st.getCursor(1)));
} finally { __sJT_ec.oracleClose(); }

Changes

 

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Changes
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.