title: Convert a Result Set from SQL Array to Array of Strings
body: <p>I am querying the <code>information_schema.columns</code> table in my PostgreSQL database. Using a table name, the result set finds all the column names, type, and whether it is nullable (except for the primary key, 'id'). This is the query being used:</p>
  
  <pre><code>SELECT column_name, is_nullable,data_type FROM information_schema.columns
  WHERE lower(table_name) = lower('TABLE1') AND column_name != 'id'
  ORDER BY ordinal_position;
  </code></pre>
  
  <p>I have a string array for each of these results and I am trying to use the ResultSet method <a href="https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSet.html#getArray-java.lang.String-" rel="noreferrer"><code>getArray(String columnLabel)</code></a> to avoid looping through the results. I want to store the returned Arrays in the string arrays, but get a type mismatch error</p>
  
  <pre class="lang-none prettyprint-override"><code>Type mismatch: cannot convert from Array to String[]
  </code></pre>
  
  <p>Is there a way to convert or typecast the SQL Array object to a String[]?</p>
  
  <p>Relevant Code:</p>
  
  <pre class="lang-java prettyprint-override"><code>String[] columnName, type, nullable;
  
  //Get Field Names, Type, &amp; Nullability 
  String query = "SELECT column_name, is_nullable,data_type FROM information_schema.columns "
          + "WHERE lower(table_name) = lower('"+tableName+"') AND column_name != 'id' "
          + "ORDER BY ordinal_position";
  
  try{
      ResultSet rs = Query.executeQueryWithRS(c, query);
      columnName = rs.getArray(rs.getArray("column_name"));
      type = rs.getArray("data_type");
      nullable = rs.getArray("is_nullable");
  }catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>