1
I have a problem in the validation of Login and Password, the code is only taken the values of the first line of the database, but when I try to put the values of the other lines it gives error, I appreciate if someone 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(); }