这是我的代码
登录框架:
try{
Class.forName("java.sql.Driver");
Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost/FoodFrame", "root", "valli99");
Statement stmt=(Statement) con.createStatement();
String username=jTextField3.getText();
String password=new String(jPasswordField1.getPassword());
String Email=new String(jTextField5.getText());
if("".equals(username) || "".equals(password) || "".equals(Email))
JOptionPane.showMessageDialog(null, "Please fill in all the fields");
else {
String query="select * from User where EmailId='"+jTextField5.getText()+"'or Username='"+jTextField3.getText()+"';";
ResultSet rs=(ResultSet) stmt.executeQuery(query);
if(rs.absolute(1)){
Toolkit.getDefaultToolkit().beep();
jTextField3.setText("");
jTextField5.setText("");
jPasswordField1.setText("");
if(Email.equals(rs.getString(4)))
JOptionPane.showMessageDialog(null, "This email has already been registered");
else if(rs.absolute(2)){
if(Email.equals(rs.getString(4)))
JOptionPane.showMessageDialog(null, "This email has already been registered");}
else
JOptionPane.showMessageDialog(null, "This username already exists");
}
boolean hasLetter = false;
boolean hasDigit = false;
if (password.length() >= 8) {
for (int i = 0; i < password.length(); i++) {
char x = password.charAt(i);
if (Character.isLetter(x)) {
hasLetter = true;}
else
if (Character.isDigit(x)) {
hasDigit = true;}
if(hasLetter && hasDigit){
break;
}
}
if (hasLetter && hasDigit) {
Statement stm=(Statement) con.createStatement();
String qy="insert into user(Username,Password, EmailID) values('"+username+"', '"+password+"', '"+jTextField5.getText()+"');";
stm.executeUpdate(qy);
JOptionPane.showMessageDialog(null, "You have successfully created an account. Please enter some more details about yourself");
String Username=jTextField3.getText();
new Details(Username).setVisible(true);
new Details().setVisible(true);
dispose();
jTextField3.setText("");
jTextField5.setText("");
jPasswordField1.setText("");
} else {
JOptionPane.showMessageDialog(null, "Password not strong.It has to be 8 characters log and should contain letters & digits");
}
} else {
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(null, "Password should have at least 8 characters");
jPasswordField1.setText("");
}
}
rs.close();
stmt.close();
stm.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage()); }// TODO add your handling code here:
}
详细信息框架
public Details(String abc) {
initComponents();
jLabel5.setText(abc);
}
//To change body of generated methods, choose Tools | Templates.
//To change body of generated methods, choose Tools | Templates.
Details() {
JOptionPane.showMessageDialog(null, "Hi"); //To change body of generated methods, choose Tools | Templates.
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String Restriction = " ";
if(jCheckBox1.isSelected())
Restriction =Restriction+" "+"Egg";
if(jCheckBox2.isSelected())
Restriction =Restriction+" "+"Dairy";
if(jCheckBox3.isSelected())
Restriction =Restriction+" "+"Seafood";
if(jCheckBox4.isSelected())
Restriction =Restriction+" "+"Poultry";
if(jCheckBox5.isSelected())
Restriction =Restriction+" "+"Nuts";
if(jCheckBox6.isSelected())
Restriction =Restriction+" "+"Gluten-free";
String age = new String((String) jComboBox1.getSelectedItem());
try{
Class.forName("java.sql.Driver");
Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost/foodframe", "root", "valli99");
Statement stmt=(Statement) con.createStatement();
String query="Update user set Name='"+jTextField1.getText()+"', Age='"+age+"', Restrictions='"+Restriction+"', Dislikes_Allergies='"+jTextArea1.getText()+"' where Username='"+jLabel5.getText()+"';";
stmt.executeUpdate(query);
String user=jLabel5.getText();
new Home_Page(user).setVisible(true);
new Home_Page.setVisible(true);
dispose();
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
该错误是由throw new UnsupportedOperationException("Not supported yet.");
语句引起的,我已将其替换为其他内容。然而,我收到错误消息&#34;尚未支持&#34;点击按钮后。请帮忙摆脱这条消息。感谢。
编辑:我添加了另一个链接到我的详细信息框架的框架。详细信息框架是显示错误消息的位置。其他帧很好。