Checking results values using Java ResultSet

0 votes

How can I check the whether there are any more values in the ResultSet as it doesn't contain any method such as hasNext()?

I tried using the below, but not sure whether it is correct or not. Please suggest.

if (!resultSet.next() ) {
    System.out.println("no data");
} 
Aug 16, 2018 in Java by anto.trigg4
• 3,420 points
26 views

1 answer to this question.

0 votes

As per my knowledge what you are doing is partially correct.

Because, initially, the ResultSet's cursor will be pointing to before the first row. Now, if the first call to next() returns false then there is no data in the ResultSet. So, you will also have to call beforeFirst() immediately in order to reset it. 

if (!resultSet.isBeforeFirst() ) {    
    System.out.println("No data"); 
} 
answered Aug 16, 2018 by code.reaper12
• 3,450 points

Related Questions In Java

0 votes
2 answers

How can I sort values of a Map in Java using its key

Assuming TreeMap is not good for you ...READ MORE

answered Oct 10, 2018 in Java by Sushmita
• 6,880 points
58 views
0 votes
2 answers

How do I get the current date and time using Java?

If you require a time stamp in ...READ MORE

answered Aug 23 in Java by Sirajul
• 25,700 points
80 views
0 votes
2 answers

How can I create File and write data in it using Java?

import java.io.BufferedWriter; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; public class WriteFiles{ ...READ MORE

answered Jul 26, 2018 in Java by samarth295
• 2,190 points
91 views
0 votes
1 answer

How can I read a large text file line by line using Java?

// Open the file FileInputStream file = new ...READ MORE

answered May 2, 2018 in Java by parth295
• 4,620 points
46 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,380 points

edited Nov 6, 2018 by Omkar 8,180 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,090 points
1,993 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,090 points
5,189 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,090 points
505 views
0 votes
1 answer

JSON parsing in Java using Gson

Well, you can easily do that by ...READ MORE

answered Nov 21, 2018 in Java by code.reaper12
• 3,450 points
421 views
0 votes
1 answer

Purpose of “String args[]” in the “psvm” of Java

Let me give you the complete explanation ...READ MORE

answered May 7, 2018 in Java by code.reaper12
• 3,450 points
87 views