I am new to oracle.I had created varray type in oracle. And now want to insert the data and set using preparedStatement. I had done same implementation in postgres using createArrayOf. But oracle does not support createArrayOf with anonymous type. I don't know how to solve it. The solution which are provided are not working for me. Because some features are deprecated in oracle.
Type that I had created:
CREATE TYPE TAGS IS VARRAY(10) OF VARCHAR2 (100)
Insert query tested in oracle:
INSERT INTO STORE(tags) VALUES (TAGS('insta','instagram','sakshi','dog','cat','cute','scorpio','poison','snake','black'))
I had tried few solutions.
1. Here I got error of createArrayOf feature not supported.
Object[] arr = request.getMetadata().getTags().toArray();
Array tag =conn.createArrayOf("TAGS", arr);
2.Here oracle.sql.Array is deprecated and second one is I don't understand what mistake I am making while creating database connection. defaultConnection() doesn't work for me and if I provide conn.getConnection without OracleConnection then createArray will not support.
`
Object[] arr = request.getMetadata().getTags().toArray();
oracle.jdbc.OracleDriver ora = new oracle.jdbc.OracleDriver();
java.sql.Connection conn = ora.defaultConnection();
oracle.jdbc.OracleConnection oraConn = (oracle.jdbc.OracleConnection) conn;
oracle.sql.Array tag = oraConn.createARRAY("TAGS", arr); `
I need to set Tags in database using java preparedStatement. Please help me. Thanks in advance