I am trying to execute the stored procedure using the java code. I am using Ojdbc 7, Jdk 1.8.
I have two databases with the same data but different versions. One with Oracle 10g and another with Oracle 12c
Plsql executes successfully and I see the fetched data in both Oracle 10g, Oracle 12c.
My Java code works fine with Oracle 10g version. But in Oracle 12c version I get the empty result.
declare
OFFERLIST_ID_TY OFFERLIST_ID_TYPES;
OFFERLIST_ID_T OFFERLIST_ID_TYPE;
OFFERS_INFO_TY OFFERS_INFO_TYPE;
begin
OFFERLIST_ID_T:=OFFERLIST_ID_TYPE('1234','MM');
OFFERLIST_ID_TY:=OFFERLIST_ID_TYPES(OFFERLIST_ID_T);
OFFERS(OFFERLIST_ID_TY,OFFERS_INFO_TY);
FOR i IN OFFERS_INFO_TY.FIRST..OFFERS_INFO_TY.LAST LOOP
DBMS_OUTPUT.PUT_LINE('Name: '|| OFFERS_INFO_TY(i).SERVICE_NAME);
END LOOP;
END;
Java class
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@db:1521:sid", "user",
"pwd");
ArrayList<Struct> OFFERListIdType = new ArrayList<Struct>();
OFFERListIdType.add(
((OracleConnection) connection).createStruct("OFFERLIST_ID_TYPE", new String[] { "1234", "MM" }));
Array array_of_records = ((OracleConnection) connection).createARRAY("OFFERLIST_ID_TYPES",
OFFERListIdType.toArray(new Struct[] {}));
CallableStatement stmt = connection
.prepareCall("{ call OFFERS(?,?) }");
stmt.setArray(1, array_of_records);
stmt.registerOutParameter(2, oracle.jdbc.OracleTypes.ARRAY, "OFFERS_INFO_TYPE");
stmt.execute();
System.out.println("Executed");
Object[] data = (Object[]) ((Array) stmt.getObject(2)).getArray();
System.out.println("Size:" + data.length);
stmt.close();
connection.close();
} catch (SQLException | ClassNotFoundException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
}
The ouput System.out.println("Size:" + data.length);
Gives empty but the same procedure gives data in the DB with the same data in oracle 10g.
Can somebody help?
This is a development database. There are many schemas for developers which share a common code base.
"there are many schemass that share common code base"
It's possible you are running into Bug 21068213, or a variant of it. There seems to be some problems in 12cR1, such that objects in one schema are confused with identical objects in another schema. Maybe it's a leak in the multi-tenancy code.
Anyway, there is a patch for this bug. So it's worth contacting Oracle Support (assuming you have a contract) to see whether this bug is what is causing your problem. Certainly get your DBAs involved.
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.