session in a desktop app in java and mysql using eclipse -


am aptech student , doing lot of projects , one. bank management , usage. authentication class want include session:

public class authenticationframe {     public static void display() {         jframe frame = new jframe("jsoft");          jpanel panel1 = new jpanel(new gridbaglayout());         panel1.setopaque(true);         panel1.setbackground(color.black);         jpanel panel2 = new jpanel(new gridbaglayout());         panel2.setopaque(true);         panel2.setbackground(color.gray);         jpanel panel3 = new jpanel(new borderlayout());         panel3.setopaque(true);         panel3.setbackground(color.gray);         gridbagconstraints cons = new gridbagconstraints();         cons.insets = new insets(5,3,5,3);          jlabel label1 = new jlabel("enter name");         label1.setforeground(color.blue);          jtextfield field1 = new jtextfield();         field1.setpreferredsize(new dimension(130,20));         field1.setforeground(color.red);           jlabel label2 = new jlabel("enter pin");         label2.setforeground(color.blue);          jpasswordfield field2 = new jpasswordfield();         field2.setpreferredsize(new dimension(130,20));         field2.setforeground(color.red);          jlabel lb = new jlabel("cb banking");          jbutton rdbtn = new jbutton("proceed");         jbutton bkbtn = new jbutton("<<");          cons.gridx = 0;         cons.gridy = 0;         panel1.add(label1, cons);         cons.gridx = 1;         cons.gridy = 0;         panel1.add(field1, cons);          cons.gridx = 0;         cons.gridy = 2;         panel1.add(label2, cons);         cons.gridx = 1;         cons.gridy = 2;         panel1.add(field2, cons);          cons.gridx = 1;         cons.gridy = 3;         panel1.add(rdbtn, cons);         panel2.add(lb);         panel3.add(bkbtn, borderlayout.west);             rdbtn.addactionlistener(new actionlistener() {              public void actionperformed(actionevent e)             {                 try{                     class.forname("com.mysql.jdbc.driver");                 }                 catch(exception er){                     joptionpane.showmessagedialog(null, er.getmessage());                 }                  try{                     if(field1.gettext().equals("") && field2.gettext().equals("")){                         joptionpane.showmessagedialog(null, "no empty fields");                     }                     else{                         connection cbcon = drivermanager.getconnection("jdbc:mysql://localhost:3306/banksystem_db", "root", "elemie");                         string username = field1.gettext();                         int pin = integer.parseint(field2.gettext());                         string query = "select fname, pin usertb fname = ? , pin = ?";                         preparedstatement cbprep = cbcon.preparestatement(query);                         cbprep.setstring(1, username);                         cbprep.setint(2, pin);                          resultset cbrs = cbprep.executequery();                         int cbresult = 0;                         while(cbrs.next()){                             cbresult+=1;                         }                         if(cbresult == 1){                             userframe.monitor_three();                             frame.dispose();                         }                         else{                             joptionpane.showmessagedialog(null,"incorrect username or password");                             field1.settext(null);                             field2.settext(null);                         }                         cbrs.close();                         cbprep.close();                     }                 }                 catch(exception er){                     joptionpane.showmessagedialog(null, er.getmessage());                 }             }         });           bkbtn.addactionlistener(new actionlistener(){             public void actionperformed(actionevent ee){                 bsystem2.monitor_one();                 frame.dispose();             }         });          frame.setsize(800, 500);         frame.setlocationrelativeto ( null );          frame.setdefaultcloseoperation(jframe.exit_on_close);         frame.setvisible(true);         frame.add(panel1);         frame.getcontentpane().add(panel2, borderlayout.north);         frame.getcontentpane().add(panel3, borderlayout.south);      }       public static void main(string[] args) {         javax.swing.swingutilities.invokelater(new runnable() {             public void run() {                 display();             }         });     } 

}

this part should work atm. user in database. suppose open userframe class


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -