Search code examples
javaoracle

java.sql.SQLException: Fail to construct descriptor error


I am using following in java code

StructDescriptor structDescriptor = StructDescriptor.createDescriptor("AF.TRANSACTIONDATATABLE", oracleConnection);

and following are my commands in db

CREATE OR REPLACE TYPE AF.TRANSACTIONDATATYPE AS OBJECT (
    no VARCHAR2(50),
    bh VARCHAR2(20),
    jb VARCHAR2(20),
    g VARCHAR2(20),
    hi VARCHAR2(30)
);

CREATE OR REPLACE TYPE AF.TRANSACTIONDATATABLE AS TABLE OF AFX_TLX_DS_USR.TRANSACTIONDATATYPE;

Still getting below

Caused by: java.sql.SQLException: Fail to construct descriptor: Invalid arguments
    at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:144)
    at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:95)

unable to understand whats wrong


Solution

  • AF.TRANSACTIONDATATABLE is a collection (Array) and not an object (Struct):

    StructDescriptor structDescriptor = StructDescriptor.createDescriptor("AF.TRANSACTIONDATATYPE", oracleConnection);
    ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor("AF.TRANSACTIONDATATABLE", oracleConnection);
    

    You can see a complete code example in this answer