how do i know the size of a resultset?

hi there,I just got a question. See i've got a resultset, which contains only one column, i want to convert that set into a array of string. so i need to know its size to define the string array.anyone can help me out here?thanks
[258 byte] By [JbloodHa] at [2007-10-2 20:19:31]
# 1
You can get the number of records by executing the query:select count(*) from <tablename>this returns number of recordc as integer.
Karthikeyan_Vaithilingama at 2007-7-13 23:01:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

A resultset doesn't have a size until you have asked it to read all the rows from the database. Since you want to get all the rows anyway, the easiest approach is to read them into a List and then convert that to an array:List rowList = new ArrayList();

while (rs.next()) {

rowList.add(rs.getString(1));

}

String[] rowArray = new String[rowList.size()];

rowArray = (String[]) rowList.toArray(rowArray);

DrClapa at 2007-7-13 23:01:40 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...