title: searching for a value in access table using java
body: <p>I have a table on my database I called it Sender table and when I want to print the content of field it gives me this error</p>
  
  <pre><code>java-sql-sqlexception [microsoft][odbc-driver-manager] invalid cursor state
  </code></pre>
  
  <p>anyway this is my code </p>
  
  <pre><code>        str = "SELECT * FROM Sender WHERE sender_PID= " + sender_PID + "";            
          try {
              rs = stmt.executeQuery (str);  
              System.out.println (rs.getInt ("sender_PID"));    
  
          } catch (Exception ex) {ex.printStackTrace ( );}
  </code></pre>
  
  <p>I,m really sorry for my bad english </p>
  
  <pre><code>database ( )
  {
      try {
  
          Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
          conn = DriverManager.getConnection ("jdbc:odbc:DB");
          stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
  
      } catch (Exception ex) {ex.printStackTrace();}
  }
  
  String checkSender (int sender_PID)
      {
          str = "SELECT sender_PID FROM Sender WHERE sender_PID= " + sender_PID + "";   
  
          try {           
              rs = stmt.executeQuery (str);                      
              while(rs.next())  
              {
                  System.out.println (rs.getInt ("sender_PID"));
              }  
  
          } catch (Exception ex) {ex.printStackTrace ( );}     
  
  
          return "1";
      }
  </code></pre>