Advertisement
Guest User

CODE

a guest
Oct 11th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.37 KB | None | 0 0
  1.   private void jButton_LOGINActionPerformed(java.awt.event.ActionEvent evt) {                                              
  2. PreparedStatement ps;
  3.         ResultSet rs;
  4.         String username = txtusername.getText();
  5.         String password = String.valueOf(txtpass.getPassword());
  6.        
  7.         String query = "SELECT * FROM `t_user` WHERE `username` =? AND `password` =?";
  8.        
  9.         try {
  10.             ps = KoneksiDB.getkoneksi().prepareStatement(query);
  11.            
  12.             ps.setString(1, username);
  13.             ps.setString(2, password);
  14.            
  15.             rs = ps.executeQuery();
  16.            
  17.             if(rs.next())
  18.             {
  19.                     F_MenuUtama mf = new F_MenuUtama();
  20.                     mf.setVisible(true);
  21.                     mf.pack();
  22.                     mf.setLocationRelativeTo(null);
  23.                     mf.setExtendedState(JFrame.MAXIMIZED_BOTH);
  24.                   //  mf.Label1.setText("Welcome < "+username+" >");
  25.                    
  26.                     this.dispose();
  27.             }
  28.             else{
  29.                     JOptionPane.showMessageDialog(null, "Incorrect Username Or Password", "Login Failed", 2);
  30.                 }
  31.            
  32.         } catch (SQLException ex) {
  33.             Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
  34.         }
  35.        
  36.        
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement