title: cannot be cast to java.sql.ResultSet
body: <p>Below shows an error message I am receiving when trying to run my code:</p>
  
  <pre><code> sun.jdbc.odbc.JdbcOdbcStatement cannot be cast to java.sql.ResultSet
  </code></pre>
  
  <p>I don't understand why this error is occurring so could someone give me the reason why or even better give me a fix to the problem. Below is the entire code</p>
  
  <pre><code>public void actionlogin()
  {
     btnLogin.addActionListener(new ActionListener() 
  {
      public void actionPerformed(ActionEvent ae) 
      {
  
          String username = txtUserName.getText();
          String password = txtPassword.getText();
  
          String databaseUsername = "";
          String databasePassword = "";
  
          String dataSourceName = "securitySystem";
          String dbUrl = "jdbc:odbc:" + dataSourceName;
  
          try{
              //Type of connection driver used    
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  
              //Connection variable or object param: dbPath, userName, password
              Connection con = DriverManager.getConnection(dbUrl, "", "");
  
              Statement statement = con.createStatement();
  
              statement.execute("select username, password  from securitySystem.employees");
  
              while (((ResultSet) statement).next()) {
                  databaseUsername = ((ResultSet) statement).getString("username");   //resultSet.getString("username");
                  databasePassword = ((ResultSet) statement).getString("password");
              }  
  
              statement.close();
              con.close();
          }catch (Exception e){
              System.out.print("Out!" +e);
          }
  </code></pre>