我在登录成功后检索确切的用户登录ID时出现问题,并将其显示在我的管理框架中的状态文本框中
public String i;
public String getId()
{
return this.i;
}
private void btnLogActionPerformed(java.awt.event.ActionEvent evt) {
String sql ="select * from ad where logId=? and password=?";
try{
pst = conn.prepareStatement(sql);
pst.setString(1,loginTxt.getText());
pst.setString(2,passTxt.getText());
rs = pst.executeQuery();
if(rs.next())
{
JOptionPane.showMessageDialog(null, "Username and password is correct"); i = rs.getString("logId");
rs.close();
pst.close();
AdminTable s = new AdminTable();
s.setVisible(true);
dispose();
}
else
{
JOptionPane.showMessageDialog(null, "Username and password incorrect");
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}
}
//这是我的第二帧,即管理框架。我希望登录ID在用户登录后自动出现在文本框中
Login lo = new Login();
public Admin() {
initComponents();
jTextAdId.setText(lo.i);
}
答案 0 :(得分:0)