aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I want to check if my ResultSet has records in it or it is empty?
 
Similar Threads
JUnit and Cactus using strutstestCase
printing on an applet
Dynamic Data Types in Eclipse
Automatically reconnect to server ?
Assert stmt in Eclipse