0

My code flows looks likes :

1. Get a list of Attributes from a particular schema. This is ArrayList in type. 
2. The method given below receives the list and does the following  
   a. It converts it to an String/Object Array. 
   b. Connects to another Schema. 
   c. Iterate through a table and get the corresponding values from a field for those attributes. 
   d. Sends back to calling method so that the same can be updated for those attributes in primary schema. 

I am getting error at following line of code :

Array itemDesc = ((OracleConnection)conn).createArrayOf("XXJN_PCM_ITEM_LIST", items);   

Error: java.sql.SQLFeatureNotSupportedException: Unsupported feature at oracle.jdbc.driver.PhysicalConnection.createArrayOf(PhysicalConnection.java:15560)

I have ojdbc6 jar linked in project and i have used the jar ojdbc7 as well. But same error all time.

Below is my code :

public HashMap MyMethod(ArrayList list) throws SQLException, Exception {
        HashMap itemsQtyMap = new HashMap();
        PreparedStatement psmt = null;
        Iterator iter = list.iterator();
        ResultSet resultSet = null;
        String itemNumber = null;
        double temp = 0;

        Object [] items = list.toArray();
        logger.info("Length of the converted array is " + items.length);
        OracleDataSource ds = new OracleDataSource();
        ds.setURL(PropertyNames.DB_URL);
        Connection conn = ds.getConnection(PropertyNames.DB_USERNAME,PropertyNames.DB_PASSWORD);
        logger.info("Connection is "+ conn);

/*This output in the logger is coming as Connection is oracle.jdbc.driver.T4CConnection@3de779fb */
        Array itemDesc = ((OracleConnection)conn).createArrayOf("XXJN_PCM_ITEM_LIST", items);   
        logger.info("Length of Item desc is "+ itemDesc);

        item = (String[]) list.toArray(item);
        Array itemDesc = ((OracleConnection) conn).createArrayOf("XXJN_PCM_ITEM_LIST", item);
*/
        oracle.sql.StructDescriptor x = StructDescriptor.createDescriptor("XXJN_PCM_ITEM_QRT_DEM", conn);
        ResultSetMetaData rsmd = x.getMetaData();
        int numberOfColumns = rsmd.getColumnCount();
        System.out.println("resultSet MetaData column Count=" + numberOfColumns);
        for (int i = 1; i <= numberOfColumns; i++) {
            logger.info("column MetaData ");
            logger.info("column number " + i);
            // get the column's name.
            logger.info(rsmd.getColumnName(i));
        }

        OracleCallableStatement cstmt = (OracleCallableStatement) conn.prepareCall("{ call xxjn_pcm_item_dem.item_qrt_dem(?,?)}");
        cstmt.setArray(1, itemDesc);
        cstmt.registerOutParameter(2, OracleTypes.ARRAY, "XXJN_PCM_ITEM_QRT_DEM_TBL");
        cstmt.execute();
        // Object[] dem = (Object[])cstmt.getObject(2);
        // Array dem = cstmt.getArray(2);
        Object[] dem = (Object[]) ((Array) cstmt.getObject(2)).getArray();

        System.out.println("length=" + dem.length);
        for (Object tmp : dem) {
            logger.info("Inside for Loop for Object TMP");
            OracleStruct row = (OracleStruct) tmp;


            Object[] attrs = row.getAttributes();

            // Attributes are index 1 based...
            // String sqlt = row.getSQLTypeName();
            //System.out.println("Item Number = " + (String) attrs[0]);
            DemandPopulationBean bean = new DemandPopulationBean();
            bean.setItemNumber((String) attrs[0]);
            bean.setQ1Demand(((BigDecimal) attrs[1]).doubleValue());
            bean.setQ1Demand(((BigDecimal) attrs[2]).doubleValue());
            bean.setQ1Demand(((BigDecimal) attrs[3]).doubleValue());
            bean.setQ1Demand(((BigDecimal) attrs[4]).doubleValue());

        }
        logger.info("---");

        //cstmt.close();
        return itemsQtyMap;
    }

Regards, MAK

6
  • If I understand correctly, are you trying to create an array from Java? Or are you trying to get the array columns from the database? Commented Apr 11, 2017 at 6:18
  • Have you tried createOracleArray() method? Commented Apr 11, 2017 at 6:26
  • Yes, tried createOracleArray() but same exception on that.Tried createARRAY() as well. What i am trying here is : 1. Convert ArrayList >> String Array 2. Array >> Create Oracle Array from it. 3. It will then call a package from code which creates a temp table on the go and gets the corresponding column. values for item mentioned in Oracle Array. Commented Apr 11, 2017 at 7:56
  • Have a look at this Commented Apr 11, 2017 at 8:04
  • How is the XXJN_PCM_ITEM_LIST type defined in the database? Commented Apr 11, 2017 at 9:25

1 Answer 1

0

The issue is resolved now. Just closed eclipse and created project from scratch, it worked this time for me. I used ojdb7 jar.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.