2
Good morning,
I have the following code in Java Desktop. I wanted to know how I can capture this user’s group and save it into a variable. Since when it returns the value and stores in the variable "rs" does not contain information understood for the developer. You need the name of the user group to open a jFrame according to their group.
public class UsuarioD {
public static Boolean doLogin(model.UsuarioM usuario) {
// Variáveis
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select * from usuario where nome=? and senha=?";
try {
// Validar
ps = ConectarDB.getConexao().prepareStatement(sql);
ps.setString(1, usuario.getNome());
ps.setString(2, usuario.getSenha());
rs = ps.executeQuery();
// Validar
if(rs.next()) {
return true;
} else {
return false;
}
} catch (SQLException ex) {
ex.printStackTrace();
return false;
}
}
}
This will also depend on how you store groups. It is a String field in the table
usuario
or in a different table?– Shura16