I have a table with this columns (id,name,isbn,borrowedStatus(varchar),Date) and some rows in my table.
Now i want to get borrowedStatus value for a specific id,then i need to recognize that String (yes, or no).
Here is my 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();
    }
}
But this code has this exception when executed:
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)
...
How can i solve this problem?
