Java -not supported yet

894 Views Asked by At

this is my code

Login frame:

  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:
}                                                    

Details frame

    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());
 }

The error is due to the throw new UnsupportedOperationException("Not supported yet."); statement which i've already replaced with something else. Yet, I'm getting the error message "not supported yet" upon clicking the button. Please help to get rid of this message. Thanks.

edit: I've added another frame which is linked to my details frame. The details frame is where the error message is being shown. The other frames are fine.

0

There are 0 best solutions below