我已经创建了一个用户登录的界面,现在我想创建另一个界面来显示登录用户的地籍数据。我想知道我是怎么做的?
是这样吗?(我创建了一个单独的接口类来查询数据库)我实例化了接口并让 textField 发送了 ResultSet 结果
public boolean checkLogin(String nick, String senha) {
Connection con = JBancoDeDados.getConnection();
PreparedStatement stmt = null;
ResultSet rs = null;
boolean check = false;
try {
stmt = con.prepareStatement("SELECT * FROM usuario WHERE Nick = ? and Senha = ?");
stmt.setString(1, nick);
stmt.setString(2, senha);
rs = stmt.executeQuery();
if (rs.next()) {
check = true;
Interface_Perfil ip = new Interface_Perfil();
ip.txtExibirNomePerfil.setText(rs.getString("Nome"));
ip.txtExibirNickPerfil.setText(rs.getString("Nick"));
ip.txtExibirSenha.setText("Senha");
ip.txtExibirEmailPerfil.setText(rs.getString("Email"));
}
} catch (SQLException ex) {
Logger.getLogger(UsuarioDAO.class.getName()).log(Level.SEVERE, null, ex);
} finally {
JBancoDeDados.closeConnection(con, stmt, rs);
}
return check;
}
一只甜甜圈
相关分类