I have a validation problem with Login and Password, the code is only taken from the values of the first row of the database, but when I try to put the values of the other lines it gives error, thank you if anyone can help me. Follow the code below.
try{
Connection con = BancoSQL.getConexao();
String sql = "select Login, Senha from cadfuncionario";
PreparedStatement ps = con.prepareStatement(sql);
ResultSet rs = ps.executeQuery(sql);
String login = jUsuario.getText();
String senha = jSenha.getText();
while(rs.next()){
if(rs.getString("Login").equalsIgnoreCase(login)
&& rs.getString("Senha").equalsIgnoreCase(senha)){
this.dispose();
MenuP m = new MenuP();
m.setVisible(true);
JOptionPane.showMessageDialog(null,"Bem vindo");
break;
}else{
JOptionPane.showMessageDialog(null,"Usuario ou Senha Incorretos!");
jUsuario.setText("");
jSenha.setText("");
}
}
}catch(Exception e){ e.printStackTrace(); }