1 回答
TA贡献1836条经验 获得超5个赞
您的代码中没有错误,只是您错过了添加ip.setVisible(true);以下行ip.txtExibirEmailPerfil.setText(rs.getString("Email"));以显示 Interface_Perfil。
下面是我的工作代码
家
login.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String Name = name.getText();
String Pass = new String(pass.getPassword());
UserAPI user = new UserAPI();
user.checklogin(Name, Pass);
}
private void setVisible(boolean b) {
// TODO Auto-generated method stub
}
});
用户接口
public boolean checklogin(String name, String Pass) throws Exception {
boolean check = false;
String sql = "SELECT * FROM admin WHERE name =? and password= ?";
DatabaseConnection db = new DatabaseConnection();
Connection conn = db.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, Pass);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
check = true;
Interface_Perfil ip = new Interface_Perfil();
System.out.println("dddd");
ip.txtExibirNomePerfil.setText(rs.getString("name"));
ip.txtExibirNickPerfil.setText(rs.getString("password"));
ip.txtExibirSenha.setText("Senha");
ip.txtExibirEmailPerfil.setText("email@hotmail.com");
ip.setVisible(true);
}
ps.close();
rs.close();
conn.close();
return check;
}
我的项目在家庭课上运行。
添加回答
举报