title: Check if ResultSet is empty in Java
body: <p>I am using HSQLDB in my program. I want to check if my Result Set is empty or not.</p>
  
  <pre><code>//check if empty first
  if(results.next() == false){
  System.out.println("empty");
  }
  
  //display results
  while (results.next()) {
  String data = results.getString("first_name");
  //name.setText(data);
  System.out.println(data);
  }
  </code></pre>
  
  <p>The above method is not working properly. According to this <a href="https://stackoverflow.com/questions/867194/java-resultset-how-to-check-if-there-are-any-results">post</a> I have to call <code>.first()</code> or <code>.beforeFirst()</code> to rest the cursor to the first row, but <code>.first()</code> and <code>.beforFirst()</code> are not supported in HSQL. I also tried to add <code>connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);</code>
  but I still get the same outcome (I get the message empty and the data from the DB!!!)
  What am I doing wrong here?</p>