title: How to get the value of a column using sql.Array in Java?
body: <p>I wrote a code which execute the query, stores the result set. I am storing the result set column-wise in different Arrays, using getArray(columnLabel) method.</p>
  
  <p>The code is here :</p>
  
  <pre><code>Array imported_by = null;
  Array imported_by_ad = null;
  Array active_directory_identity_value = null;
  while (rs.next()) {
          imported_by = rs.getArray(column_id);
          imported_by_ad = rs.getArray(column_id + 1);
          active_directory_identity_value = rs.getArray(column_id + 2);
          row_count++;
          }
  </code></pre>
  
  <p>Now I would like to print the result set index-by-index that is what we usually do while printing List:</p>
  
  <pre><code>for(int i=0;i&lt;=row_count;i++){
            System.out.println(imported_by.get(i) + " " + imported_by_ad.get(i) + " " 
                               + active_directory_identity_value.get(i));
  </code></pre>
  
  <p>get(i) method cannot be used for object type Array, but is there any other method to store the resultset in some list and access/read it as much and whenever I can?</p>
  
  <p>Let me know :)</p>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong>: I also type cast the variable but unfortunately it is throwing exception now:
  The updated code is :</p>
  
  <pre><code>try {
          int row_count = 0;
          ArrayList&lt;String&gt; imported_by = null;
          ArrayList&lt;String&gt; imported_by_ad = null;
          ArrayList&lt;String&gt; active_directory_identity_value = null;
          while (rs.next()) {
              imported_by = (ArrayList&lt;String&gt;) rs.getArray(column_id);
              imported_by_ad = (ArrayList&lt;String&gt;) rs.getArray(column_id + 1);
              active_directory_identity_value = (ArrayList&lt;String&gt;) rs.getArray(column_id + 2);
              row_count++;
          }
  </code></pre>
  
  <p>}</p>
  
  <p>and the exception is </p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.UnsupportedOperationException    at
    sun.jdbc.odbc.JdbcOdbcResultSet.getArray(JdbcOdbcResultSet.java:4395)</p>
  </blockquote>