java - Login dialog doesn't display welcome -


when enter username , password, , click on login button, welcome.java doesn't open, shows output message dialog box. doesn't open welcome.java. there no error in coding; neither coding nor connection. after login, welcome.java should open, doesn't open @ all. please help

string path = "jdbc:mysql://localhost/"; string place = "hotel";  try {     class.forname("com.mysql.jdbc.driver");     connection myconnection = drivermanager.getconnection(path + place, "root", "");     try {         string = "select usertype usertable username=? , password=? ";         preparedstatement mystatement = myconnection.preparestatement(a);         mystatement.setstring(1, username.gettext());         mystatement.setstring(2, password.gettext());                resultset myresult;         myresult = mystatement.executequery();         if (myresult.next()) {             if (myresult.getstring("usertype").equals("admin")) {                  joptionpane.showmessagedialog(rootpane, "admin");                 parent1 obj = new parent1();                 obj.setvisible(true);              } else if (myresult.getstring("usertype").equals("client")) {                  joptionpane.showmessagedialog(rootpane, "client");                 welcome2 obj = new welcome2();                 obj.setvisible(true);             } else {                 joptionpane.showmessagedialog(rootpane, myresult.getstring("usertype"));              }             //this.setvisible(false);         } else {             joptionpane.showmessagedialog(rootpane, "wrong username/password");         }         mystatement.close();         myconnection.close();     } catch (exception e) {         joptionpane.showmessagedialog(rootpane, "error in query" + e.getmessage());     } } catch (exception e) {     joptionpane.showmessagedialog(rootpane, "error in connection" + e.getmessage()); } } 

try code; although question bit unclear.. hope code helps ..

    try{             if(!myresult.next()){            //no logins found,login failes            joptionpane.showmessagedialog(null, "invalid login details... try again","alert!",joptionpane.error_message);           }else{            //found record,login succeeded              if (myresult.getstring("usertype").equals("admin")) {                     joptionpane.showmessagedialog(rootpane, "admin");                      parent1 obj = new parent1();                     obj.setvisible(true);                     this.dispose();              } else if (myresult.getstring("usertype").equals("client")) {                      joptionpane.showmessagedialog(rootpane, "client");                      welcome2 obj = new welcome2();                     obj.setvisible(true);                     this.dispose();              }        }             }catch(sqlexception | headlessexception e){                 joptionpane.showmessagedialog(null, "wrong "+e);            }finally{                 try{                    pst.close();                 }catch(exception e){                    joptionpane.showmessagedialog(null, "errorr "+e);                 }            } 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -