日期:2014-05-20 浏览次数:20744 次
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt){ try { Connection con=DriverManager.getConnection(dbURL,userName,userPwd); Statement sql=con.createStatement(); String uname=jTextField1.getText().trim(); String passwd=jPasswordField1.getText().trim(); // this.uName=jTextField1.getText().trim(); String sel="select * from [User] where uName='"+uname+"'and Passwd='"+passwd+"'"; ResultSet rs=sql.executeQuery(sel); if(rs.next()) { // new UpUaP2(); new UpUaP2(uname).setVisible(true); this.hide(); con.close(); } else { System.out.println("<html><font color=#FF0000 size='4'>没有相关用户!请检查后再输入!</font>"); jTextField1.setText(""); jPasswordField1.setText(""); } } catch(Exception e) { System.out.println("errCode: "+e.toString()); System.out.println("err: "+e.getMessage()); }}
public UpUaP2(String uName){} private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: System.exit(0); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: 加载驱动没问题,略去代码 try { Connection con=DriverManager.getConnection(dbURL,userName,userPwd); Statement sql=con.createStatement(); String uname=jTextField1.getText().trim(); String passwd=jTextField2.getText().trim(); String upU="updata [User] set uName='"+uname+"'and Passwd='"+passwd+"' where uName='"+this.uName+"'"; String upU2="updata [User] set Passwd='"+passwd+"' where uName='"+this.uName+"'"; if(uname==" "||uname.equals(null)) { sql.execute(upU2); System.out.println("更改成功!"); } else { sql.execute(upU); System.out.println("更改成功!"); } } catch(Exception e) { System.out.println("errCode: "+e.toString()); System.out.println("err: "+e.getMessage()); }