(1) 使用MD5 加密添加到account_password 表中并使用这个基本验证是否能登录
try {
this.test.get_sql_connection();
this.test.ps = this.test.ct.prepareStatement(sql);
this.test.ps.setString(1, a);
this.test.ps.setString(2,this.md5.getMd5_String(b)) ;
this.test.rs = this.test.ps.executeQuery();
flag=this.test.rs.next();
}
catch (Exception e) {
}
finally {
this.test.close();
}
if (flag == true) {
if (this.windows == null) {
this.windows = new Windows(this, this.test);
}
(2) 增强程序的健壮性
if(actionEvent.getSource().equals(this.jb_delete)) {
String a = this.jt_delete.getText();
if (a.equals("")) {
JOptionPane.showMessageDialog(this,"ERROR 检查输入!!");
} else {
try {
this.test.delete(a);
JOptionPane.showMessageDialog(this, "delete ok!!!");
} catch (Exception e) {
JOptionPane.showMessageDialog(this, "ERROR!!!");
}
}
}
数据库的连接以及相应的SQL 语句应该是没有错误的,因此我选择将TEST这个类中的方法抛出,在catch中提示信息。
(3) 最后在修改一下,基本也就完成了