This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display no results

 
Jardel Tan
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i'm having problems with my search logic
if (rs!=null){
while(rs.next())
{
}
}
else
{
out.println("no results")
}
it seem that if no results from databases
it woudn't display "no results"
can anyone pls help me..
thanx
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first result is always empty, so the coe you are looking for is:

You could get more specific information in the JDBC forum.
Dave.
 
Pranit Saha
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if(rs!=null)
{
if(rs.next())
{
//display result
}
else
{
//Not exist
}
}
Hope this will work fine..
Pranit.
Originally posted by Jardel Tan:
hi i'm having problems with my search logic
if (rs!=null){
while(rs.next())
{
}
}
else
{
out.println("no results")
}
it seem that if no results from databases
it woudn't display "no results"
can anyone pls help me..
thanx

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17625
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As you can see, there's more than one way to do it. I like this one:
 
java alltheway
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use this to find out if there's data back from database. This will show you how many rows are in the resultset.
int rowcnt=0;
rs.last();
rowcnt = rs.getRow();
 
Jardel Tan
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah! u guys r great!
thanx
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic