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.
The code is here :
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++;
}
Now I would like to print the result set index-by-index that is what we usually do while printing List:
for(int i=0;i<=row_count;i++){
System.out.println(imported_by.get(i) + " " + imported_by_ad.get(i) + " "
+ active_directory_identity_value.get(i));
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?
Let me know :)
Thanks.
Update: I also type cast the variable but unfortunately it is throwing exception now: The updated code is :
try {
int row_count = 0;
ArrayList<String> imported_by = null;
ArrayList<String> imported_by_ad = null;
ArrayList<String> active_directory_identity_value = null;
while (rs.next()) {
imported_by = (ArrayList<String>) rs.getArray(column_id);
imported_by_ad = (ArrayList<String>) rs.getArray(column_id + 1);
active_directory_identity_value = (ArrayList<String>) rs.getArray(column_id + 2);
row_count++;
}
}
and the exception is
Exception in thread "main" java.lang.UnsupportedOperationException at sun.jdbc.odbc.JdbcOdbcResultSet.getArray(JdbcOdbcResultSet.java:4395)