I am having an arraylist of objects and trying to insert the list into HANA. So my insert code looks like
PreparedStatement stmt = conn .prepareStatement("INSERT INTO SCHEMA.TABLE VALUES"+" (?, ?, ?, ?, ?, ?, ?, ARRAY("+"1,2,3"+")");for (int i = 1; i <= ITERATION_MAX; i++) { stmt.setInt(1, listofdata.get(i).get_id()); stmt.setInt(2, listofdata.get(i).get_name()); stmt.setInt(3, listofdata.get(i).get_place()); stmt.setInt(4, listofdata.get(i).get_year()); stmt.setInt(5, listofdata.get(i).get_day()); stmt.setInt(6, listofdata.get(i).get_rollno()); stmt.setInt(7, listofdata.get(i).get_main_subject()); stmt.setArray(8, listofdata.get(i).get_elective()); stmt.addBatch();}stmt.executeBatch();
Here listofdata.get(i).get_elective()
returns an integer array.
But this does not work. According to my program ARRAY function is called each time but why does not it inserting into HANA database. So after a while I understood that I have to convert JAVA Array into HANA Array. How can I convert a java Array to HANA Array.
Any help is appreciated.