Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to know the rows are fetched or not?

 
Deepa Balasubramanayam
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Deepa Balasubramanayam
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Phil Hanna
-Deepa
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic