• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

display no results

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Saloon Keeper
Posts: 28486
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you can see, there's more than one way to do it. I like this one:
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah! u guys r great!
thanx
 
Anything worth doing well is worth doing poorly first. Just look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic