当前位置: 代码迷 >> J2SE >> J2SM有关问题
  详细解决方案

J2SM有关问题

热度:115   发布时间:2016-04-24 01:30:40.0
J2SM问题
我要2个界面,在第一界面完成后跳转到第二个界面,可是总是出现错误,第二界面不是空白的就是无法调用,求帮忙!第一个界面代码:
Java code
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());         }}

第二界面代码:
Java code
  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());         }
在线等,急求解!!!!用的是NetBeans 的图形界面设计

------解决方案--------------------
String sel="select * from [User] where uName='"+uname+"'and Passwd='"+passwd+"'";
没想通为什么是[User]。数据库中表名难道是这样写的?
  相关解决方案