I have a stored procedure in Oracle like below.
create or replace TYPE T_EMP_OBJ AS OBJECT (Name varchar2(20), Age CHAR(3 CHAR));
create or replace type T_EMP_REC as table of T_EMP_OBJ;
create or replace PROCEDURE P_EMP (I_NAV_REC IN T_INAV_REC, p_out OUT MY_TYPES_PKG.REFCURSOR)
AS ...
END P_EMP;
I am calling that procedure from java. My code is,
StructDescriptor structDesc = new StructDescriptor("T_EMP_OBJ", oracleConnection);
ArrayDescriptor arrayDesc2 = new ArrayDescriptor("T_EMP_REC", oracleConnection);
Object[] objType = new Object[2];
objType[0] = new String("AAA");
objType[1] = new String("25");
STRUCT struct = new STRUCT(structDesc, oracleConnection, objType);
STRUCT[] structs = new STRUCT[1];
structs[0] = struct;
oracle.sql.ARRAY array = new oracle.sql.ARRAY(arrayDesc2, oracleConnection, structs);
OracleCallableStatement statement = (OracleCallableStatement) oracleConnection.prepareCall("CALL P_EMP(?,?)");
statement.setArray(1, array);
statement.registerOutParameter(2, oracle.jdbc.OracleTypes.CURSOR);
statement.execute();
ResultSet results = ((OracleCallableStatement) statement).getCursor(2);
while (results.next()) {
logger.info("NAME==>"+results.getString(1));
logger.info("AGE===>"+results.getString(2));
}
Eventhough I am getting records, the value is null. That means if the output is 2 rows, then the while condition executing and printing null. In SQL Developer it is working fine. Thanks in advance.
Finally found the answer here . After including the orai18n.jar in class path, it is working fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.