aspose file tools*
The moose likes Servlets and the fly likes How to know the rows are fetched or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to know the rows are fetched or not?" Watch "How to know the rows are fetched or not?" New topic
Author

How to know the rows are fetched or not?

Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
Hi,
I coded the following statement to select rows from the JobTable for a particular skills. If the there is no row for that
skills I want to display "No matches found " for that skills. My question is what I have to code to find out whether the SQL query fetched rows or not.
ResultSet rs = statement.executeQuery("Select * "+
from JobTable where Skills = " +var_WhereClause );
Thanks
Deepa


------------------
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
Several ways:

If you need to do something special on the first row (like produce a heading), you can add a test:

or, alternatively:

The "do ... while" is necessary in the last case because the "if (rs.next())" line consumes the first row, so you can't do a for loop.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Deepa Balasubramanayam
Ranch Hand

Joined: Mar 29, 2001
Posts: 39
Thanks a lot Phil Hanna
-Deepa
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to know the rows are fetched or not?