Resultset problem

Hi all,

I encountered a problem executing the following code:

/********************************************************************/

ResultSet rset = sql_stmt.executeQuery("select NAME from test");

rset.last();

int size=rset.getRow();

rset.first();

int fileInd=0;

while (rset.next())

{

fileName[fileInd] = rset.getString(1);

fileInd++;

}

/********************************************************************/

the code after

"rset.last();

int size=rset.getRow();

rset.first();" will not execute. but if I comment these three lines(I used it to get the number of rows selected), then the rest of the program will execute correctly.

Does anyone knows what's the problem? Did I do anything wrong?

Thanks in advance!

Karen

[845 byte] By [karenJJa] at [2007-11-27 10:17:21]
# 1

What do you mean "does not execute"?

Why are you getting the size anyway, since you're not using it?

jverda at 2007-7-28 15:51:12 > top of Java-index,Java Essentials,Java Programming...
# 2

Most ResultSets can only be read forward.

tjacobs01a at 2007-7-28 15:51:12 > top of Java-index,Java Essentials,Java Programming...
# 3

If you're trying to create an array the size of the result set to hold the data, do yourself a favour and use a collection:

http://java.sun.com/docs/books/tutorial/collections/index.html

BigDaddyLoveHandlesa at 2007-7-28 15:51:12 > top of Java-index,Java Essentials,Java Programming...