hi,
i know this is kind silly question, but i just can not find answer for this.
after i query the sql statement, how can i get the count of the records found from ResultSet?
You can do something like this:
//(rs is your result set)
int count=0;
while(rs.next())
count ++;
}
rs.first();
System.out.println("The size of the result set is: "+count);
hi Alex,
thx for ur help.
Your code is working, but that is not what i wanted. I mean, before i run the
while(rs.next()) {
...
}
i need to know how many records are found from ResultSet. Therefore, i can have fixed array size and use in 'rs.next()'.
any ideas?
I don't think there is a way to query the rs for its size.
The solution I wrote will allow you to get the number for your array and then use rs.first() to move the rs "back to the beginning" as Inigo might say.
If this is a solution you've tried, but for speed you don't want to loop through the whole result set just to set an array size, I don't know what to tell you. Maybe use a vector?
Sorry if this response is repeating info you already know.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.