File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply 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
printing on an applet
JUnit and Cactus using strutstestCase
Assert stmt in Eclipse
Dynamic Data Types in Eclipse
Automatically reconnect to server ?