I'm getting an ARRAY from oralce sql in java and write it to java.sql.ARRAY. This array is type of VARRAY of OBJECT. How can I convert this type to ArrayList?
Assuming you actually are getting an array of String[], you should be able to use something like -
public static List<String[]> getList(ResultSet rs) throws IOException, SQLException {
List<String[]> al = new ArrayList<String[]>();
java.sql.Array z = rs.getArray("my_array_column");
for (Object obj : (Object[])z.getArray()) {
try {
String [] arr = (String[]) obj;
al.add(arr);
} catch (ClassCastException e) {
System.out.println("Object is not a String[]");
e.printStackTrace();
}
}
return al;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With