File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes display no results Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "display no results" Watch "display no results" New topic
Author

display no results

Jardel Tan
Greenhorn

Joined: Sep 11, 2001
Posts: 14
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Sep 09, 2001
Posts: 130
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

Joined: Jun 25, 2001
Posts: 15950
    
  19

As you can see, there's more than one way to do it. I like this one:


Customer surveys are for companies who didn't pay proper attention to begin with.
java alltheway
Greenhorn

Joined: Oct 03, 2001
Posts: 5
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

Joined: Sep 11, 2001
Posts: 14
yeah! u guys r great!
thanx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display no results
 
Similar Threads
JTable of result, Is its items selectable to invoke another page
Pagewise Results
displayTag: pagination (link for display all)
OutOfMemory with 2000 records.
logic to display certain number of records in JSP