private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            SQLConnection MyCon = new SQLConnection();
            Connection c = MyCon.getConnection("journal");
            Statement stmt = c.createStatement();
            String name = MyCon.getUsername();
            String checkname;
            String SQL = "select * from journal.profile where username='"+name+"';",txt ="";
            ResultSet rs = stmt.executeQuery(SQL);
                    while(rs.next()){
                        checkname = rs.getString("username");
                        if(checkname.toUpperCase().equals(name.toUpperCase())){
                            txt = rs.getString("password").toString();
                            break;
                        }
                    }
            SQLConnection mycon = new SQLConnection();
                    User u = new User();
                       
                            if(password3.getText().equals(password1.getText())){
                                jLabel1.setVisible(false);
                                if(password2.getText().equals(txt)){
                                    u.setPassword(password3.getText());
                                    SQL = "update profile set "
                                    + "password='"+u.getPassword()+"' "
                                    + "where username = '"+name+"';";
                                    stmt.executeUpdate(SQL);      
                                    this.dispose();
                                }else{
                                    jLabel1.setText("Old passwords don't match");
                                    jLabel1.setVisible(true);
                                }
                                
                                
                            }else{
                                jLabel1.setText("Passwords don't match");
                                jLabel1.setVisible(true);
                            } 
                       
        } catch (SQLException ex) {
            Logger.getLogger(ChangePassword.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton1ActionPerformed