This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes I want to check if my ResultSet has records in it or it is empty? 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 » Databases » JDBC
Bookmark "I want to check if my ResultSet has records in it or it is empty?" Watch "I want to check if my ResultSet has records in it or it is empty?" New topic
Author

I want to check if my ResultSet has records in it or it is empty?

Constantinos Grevenitis
Ranch Hand

Joined: Nov 29, 2006
Posts: 31
I thought that wasNull() was the one a I was wrong. Is there any method that checks that or do I have to do it "manually"?
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Hi Constantinos,
You can try rs.next() which return a boolean value indecating that whether ResultSet has any record or not.

To explain more, When you execute a query and it return a resultset, resultset pointer is before first row, when you call resultSet.next() it trys to move to first rows and if the row is not present it will return false.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to check if my ResultSet has records in it or it is empty?
 
Similar Threads
Assert stmt in Eclipse
Dynamic Data Types in Eclipse
JUnit and Cactus using strutstestCase
Automatically reconnect to server ?
printing on an applet