title: Retrive a single value via resultset and compare it with a String value
body: <p>I have a table with this columns (<code>id</code>,<code>name</code>,<code>isbn</code>,<code>borrowedStatus</code>(varchar),<code>Date</code>) and some rows in my table.</p>
  
  <p>Now i want to get <code>borrowedStatus</code> value for a specific <code>id</code>,then i need to recognize that String (yes, or no).
  Here is my code:</p>
  
  <pre><code>public void booksTableBorrowChanged(int rowInModel) {
      Object bookId = this.getValueAt(rowInModel, 0);
      Connection con;
      PreparedStatement ps1;
      String query1 = "select borrowedStatus from books where id=" + bookId;
      ResultSet rs = null;
      try {
          con = DriverManager.getConnection(...);
          ps1 = con.prepareStatement(query1);
          rs = ps1.executeQuery();
          if (String.valueOf(rs.getString("BorrowedStatus")).equalsIgnoreCase("No")) {  // then do Borrow Action
              System.out.println("Old statuse : No");
  
             // then do other stuff
  
          }
  
      } catch (SQLException sqle) {
          sqle.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>But this code has this exception when executed:</p>
  
  <pre><code>java.sql.SQLException: Before start of result set
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
  at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
  ...
  </code></pre>
  
  <p>How can i solve this problem?</p>