LogIn Multiple Users Java [duplicate]

D

David Romero

Guest
This question already has an answer here:


I'm trying to do a LogIn for more than two users, my SQL syntax is correct. For a reason I can't see to understand is not validating my access. Any help/ideas?

public int LogIn(LogIn log) {
System.out.println("Bienvenido al DAO");
r = 0;
System.out.println(log.getuser());
System.out.println(log.getpass());
String sql = "SELECT * FROM `user` WHERE user = '" + log.getuser() + "' AND pass = '" + log.getpass() + "'";
System.out.println(sql);
try {
con = cn.getConnection();
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
System.out.println("Succesfull in DAO");
r = r + 1;
System.out.println(r + "hhh");
l.setGrado(rs.getString("type"));
l.setuser(rs.getString("user"));
l.setpass(rs.getString("pass"));
} if (r==1){
return r;
} else {
r--;
return r;
}
} catch (Exception e) {
return r;
}
}


If you wish to see any other code within the project, let me know! Thanks for the help in advance,

This is what my console is printing in return.

Info: Bienvenido al DAO
Info: admin
Info: 123
Info: SELECT * FROM `user` WHERE user = 'admin' AND pass = '123'
Info: 0


Stack trace

Continue reading...
 
Top