看下try里面的语句有问题吗?怎么直接执行catch?谢谢
publicvoidactionPerformed(ActionEvente){Stringid="";Stringpassword;Stringpassword_aga...
public void actionPerformed(ActionEvent e) {
String id="";
String password;
String password_again;
try { String uri="jdbc:derby:Information;create=true";
con=DriverManager.getConnection(uri);
SQL="INSERT INTO yonghu VALUES(?,?,?,?,?,?)";
sql=con.prepareStatement(SQL);
id=view.inputID.getText().trim();
char [] a=view.inputPassword.getPassword();
password = new String(a);
a =view.inputPassword_again.getPassword();
password_again = new String(a);
if(!(password.equals(password_again))) {
JOptionPane.showMessageDialog
(null,"密码不一致","消息对话框",JOptionPane.WARNING_MESSAGE);
return;
}
sql.setString(1,id);
sql.setString(2,view.inputName.getText().trim());
sql.setString(3,password.trim());
sql.setString(4,view.inputBirth.getText().trim());
sql.setString(5,view.inputMajor.getText().trim());
sql.setString(6,view.inputBanji.getText().trim());
m=sql.executeUpdate();
con.close();
}
catch(SQLException exp) {
JOptionPane.showMessageDialog
(null,"请换id","消息对话框", JOptionPane.WARNING_MESSAGE);
} 展开
String id="";
String password;
String password_again;
try { String uri="jdbc:derby:Information;create=true";
con=DriverManager.getConnection(uri);
SQL="INSERT INTO yonghu VALUES(?,?,?,?,?,?)";
sql=con.prepareStatement(SQL);
id=view.inputID.getText().trim();
char [] a=view.inputPassword.getPassword();
password = new String(a);
a =view.inputPassword_again.getPassword();
password_again = new String(a);
if(!(password.equals(password_again))) {
JOptionPane.showMessageDialog
(null,"密码不一致","消息对话框",JOptionPane.WARNING_MESSAGE);
return;
}
sql.setString(1,id);
sql.setString(2,view.inputName.getText().trim());
sql.setString(3,password.trim());
sql.setString(4,view.inputBirth.getText().trim());
sql.setString(5,view.inputMajor.getText().trim());
sql.setString(6,view.inputBanji.getText().trim());
m=sql.executeUpdate();
con.close();
}
catch(SQLException exp) {
JOptionPane.showMessageDialog
(null,"请换id","消息对话框", JOptionPane.WARNING_MESSAGE);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询