title: How to use a same resultset twice in Java
body: <p>I would like to use <strong>same</strong> result set twice, once is to check whether it is empty and execute code based on the result, and then, using <code>(resultset.next()</code> the second result set will always skip a line because of the first result set</p>
  
  <p>Here's my code so far : </p>
  
  <pre><code>connection = DriverManager.getConnection(connection);
  statement = (Statement) connection.createStatement();
  resultset = statement.executeQuery(query);
  
  String id = "0";
  String idfromdb;
  
  if(resultset.next() == false){
    System.out.println("table is empty")
    statement.executeUpdate(" INSERT INTO table VALUES ('value') ");
  }
  
  else{
    while(resultset.next()){
      idfromdb = resultset.getString("value")
      if(! idfromdb = id){
        System.out.println("no similar data has been found");
      }    
      else{
        System.out.println("similar data has been found");
      }
    }
  }
  </code></pre>