My Oracle Support Banner

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

Last updated on MAY 02, 2011

Applies to:

SQLJ - Version: and later   [Release: 11.1 and later ]
Information in this document applies to any platform.


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(
at oracle.jdbc.driver.DatabaseError.throwSqlException(
at Main.main(

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())
// execute statement
// retrieve OUT parameters
iter = new Main.EmpIter(new sqlj.runtime.ref.OraRTResultSet(__sJT_st.getCursor(1)));
} finally { __sJT_ec.oracleClose(); }


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

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