title: Check if record exists in database with resultset
body: <p>I want to check if an int value exists in my database. I have 2 classes, one class where I make the jdbc connection (the method is called "checkid"):</p>
  
  <pre><code>Statement stmt = null;
  String query = SELECT * FROM Table1 WHERE id = ?";
  try {
      stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery(query);
      if (rs != null){
      System.out.println("result set has got something"); 
      while (rs.next())
      { 
          //NOW YOU'RE ON ROW 1
      }
  } else {
      out.println("result set is empty");  
  } catch (SQLException e ) {
      JDBCTutorialUtilities.printSQLException(e);
  }
  </code></pre>
  
  <p>And a class where i call this method and now my question is. How can i check if the record exists?
  I think it is something like this:</p>
  
  <pre><code>int id = 10; 
  JDBCClass jdbcClass = new JDBCClass ();
  if (jdbcClass.checkid(id) == null)
      System.err.println("null");
  </code></pre>