Hi,
I've read quite a few posts on ResultSets today, but I can't seem to find a satisfactory answer to what I want.
I'm executing an SQL query, then if the ResultSet has no rows (i.e. it's 'empty') then I want to tell the user that their search has no hits. If there are rows, I want to display them.
The problem that I have is that even if I make my statement scrollable, I can't seem to get back to the first row.
Statement S = C.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
ResultSet rs = S.executeQuery ("SELECT * FROM etc, etc, .......);
rs.last ();
int rowCount = rs.getRow ();
rs.first ();
if (rowCount > 0)
{
//...print out the results
}
else
{
out.println ("No results found");
}
When I do this, the printed result set is always missing the first row of the results. Is there any other way around this other than reading the ResultSet into an ArrayList and then counting it?
Many thanks,
Graham