Originally posted by George Larry:
I thought I could do this...
String[] listNames = rs.getArray( "name" );
But that's not working...
It would work only for SQL3 Datatypes, if the Database column type is SQL ARRAY, which means each field contains an actual array.
But in your case each field contains a String.
To convert your resultset into an array you have to step through the resultset row by row to fetch the values and write them to the array.
So your code should look somehow like this:
query = "select distinct name from table";
rs = stmt.executeQuery(query);
int i = 0;
while (rs.next()) {
listNames[i] = rs.getString(1);
i++
}
make shure the array listNames is large enough. If you are not shure how many names the result contains you can use a "count distinct name from table" first to find it out and size the array correctly, or you could collect the data into a vector and copy the vector into the array.
BTW: This question should actually be posted in the JDBC-forum.
sl
Hartmut