try {
Connection c = DB.getCon();
Statement s = c.createStatement();
s.executeUpdate("INSERT INTO login(LogID, UserName, Password) VALUES('"+jTextField1.getText()+"', '"+jTextField2.getText()+"', '"+jPasswordField1.getPassword()+"')");
} catch (Exception e) {
e.printStackTrace();
}
autoGen();
clear();
我将其编码为我的新登录帐户创建表单但密码是加密保存的然后我将登录页面编码为这样它想做任何事情并且没有错误
String user = jTextField1.getText();
String pass = new String(jPasswordField1.getPassword());
try {
ResultSet rs = DB.getCon().createStatement().executeQuery("select * from login where UserName='" + user + "' and Password = '" + pass + "'");
if (rs.first()) {
if (rs.first()) {
Main_Page pat1 = new Main_Page();
pat1.setVisible(true);
Login_Page.this.setVisible(false);
} else {
jLabel6.setText("Login faild");
}
}`enter code here`
} catch (Exception e) {
e.printStackTrace();
}
谁来帮帮我
检查您提供的代码,一个问题似乎是您有冗余/嵌套的if语句,外部if语句上没有else子句。如果在查询中没有找到该帐户,这将导致您描述的行为。尝试删除外部if语句