Thursday, 22 June 2017

JavaEE : oracle.jdbc.OracleTypes for CallableStatement.registerOutParameter with SYS_REFCURSOR ~ GNIITHELP

This is a procedure which has one out parameter of SYS_REFCURSOR type. 
PROCEDURE p_get_data(query_result OUT SYS_REFCURSOR);

In java for working out with this procedure you need to import ojdbc14.jar and need to set registerOutParameter type as OracleTypes.CURSOR 
import oracle.jdbc.driver.OracleTypes;

CallableStatement callStmt = connection.prepareCall("{call p_get_data(?)}");
callStmt.registerOutParameter(1, OracleTypes.CURSOR);
callStmt.execute();
ResultSet resultSet = (ResultSet) callStmt.getObject(1);
if(resultSet.next()) {
//Your Code here
}

No comments:

Post a Comment