Convert a Result Set from SQL Array to Array of Strings Convert a Result Set from SQL Array to Array of Strings arrays arrays

Convert a Result Set from SQL Array to Array of Strings


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();


How to set an ArrayList property from an SQL Array:

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