title: No data found Java exception
body: <p>I'm new to Java and working on a project. i am trying to retrieve data from MS Access with the use of Netbeans. It was all working fine untill i reinstalled my operating system. Now wen i run the code I get this error. Your help and advice would be much appreciated</p>
  
  <pre><code>java.sql.SQLException: No data found
      at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7138)
      at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
      at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
      at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
      at java.sql.DriverManager.getConnection(DriverManager.java:582)
      at java.sql.DriverManager.getConnection(DriverManager.java:185)
      at connect.ConnectDB(connect.java:24)
      at StaffLogin.formWindowOpened(StaffLogin.java:125)
      at StaffLogin.access$000(StaffLogin.java:13)
      at StaffLogin$1.windowOpened(StaffLogin.java:47)
      at java.awt.Window.processWindowEvent(Window.java:1859)
      at javax.swing.JFrame.processWindowEvent(JFrame.java:279)
      at java.awt.Window.processEvent(Window.java:1820)
      at java.awt.Component.dispatchEventImpl(Component.java:4630)
      at java.awt.Container.dispatchEventImpl(Container.java:2099)
      at java.awt.Window.dispatchEventImpl(Window.java:2475)
      at java.awt.Component.dispatchEvent(Component.java:4460)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
      at  java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at  java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  </code></pre>
  
  <p>This is the code, I have left out the 'generated code' and the 'look and feel' also. please let me know if these are needed. Thanks.</p>
  
  <pre><code>import java.sql.*;
  import javax.swing.*;
  
  public class StaffLogin extends javax.swing.JFrame {
  
  Connection conn = null;
  ResultSet rs = null;
  PreparedStatement pst = null;
  
  /**
   * Creates new form StaffLogin
   */
  public StaffLogin() {
      initComponents();
  }
     private void formWindowOpened(java.awt.event.WindowEvent evt)  {                                  
      // TODO add your handling code here:
      conn = connect.ConnectDB();
  }                                 
  
  private void cmdloginMouseClicked(java.awt.event.MouseEvent evt)  {                                      
      // TODO add your handling code here:
      conn = connect.ConnectDB();
     String u = txtusername.getText();
     String p = txtpassword.getText();
  
      String sql = "SELECT * FROM Staff_Table WHERE Firstname='" + u+"' and Password='"+ p+"'";
      try{
          pst = conn.prepareStatement(sql);
          rs = pst.executeQuery();
          if (rs.next()){
              JOptionPane.showMessageDialog(null,"Correct Password");
              Interface i = new Interface();
              i.setVisible(true);
  
          }
          else
              JOptionPane.showMessageDialog(null,"Invalid Username or Password");
      }
      catch(Exception e){
          JOptionPane.showMessageDialog(null, e);
      }
  }                                     
  
  /**
   * @param args the command line arguments
   */
  public static void main(String args[]) {
  java.awt.EventQueue.invokeLater(new Runnable() {
  
          public void run() {
              new StaffLogin().setVisible(true);
          }
      });
  }
  // Variables declaration - do not modify                     
  private javax.swing.JButton cmdlogin;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPasswordField txtpassword;
  private javax.swing.JTextField txtusername;
  // End of variables declaration                   
  </code></pre>
  
  <p>}</p>