Convert a Result Set from SQL Array to Array of Strings

How to set an ArrayList property from an SQL Array:

Array a = rs.getArray("col"); // smallint[] column
if (a != null) {
    yourObject.setListProperty(Arrays.asList((Integer[]) a.getArray()));
}

this can be helpful

Object[] balance = (Object[]) ((Array) attributes[29]).getArray();
        for (Object bal : balance) {

            Object [] balObj =(Object[]) ((Array) bal).getArray();
            for(Object obj : balObj){
                Struct s= (Struct)obj;
                if(s != null ){
                    String [] str = (String[]) s.getAttributes();
                    System.out.println(str);
                }

            }

        }

Use:

Array a = rs.getArray("is_nullable");
String[] nullable = (String[])a.getArray();

As explained here

Array is SQL type, getArray() returns an object to cast to java array.


Generalize the Array to Object

    Object[] type; //this is generic can use String[] directly
    Array rsArray;

    rsArray = rs.getArray("data_type");
    type = (Object [])rsArray.getArray();

Use it loop as string:

type[i].toString();