Guest User

Untitled

a guest
Apr 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. void Masuk(){
  2.         try{
  3.             Mysqlkoneksi kon = new Mysqlkoneksi();
  4.             Connection con = kon.getConnection();
  5.             Statement st = con.createStatement();
  6.             String sqllogin = "SELECT * FROM user WHERE username='"+txt_username.getText()+"'";
  7.             ResultSet rs = st.executeQuery(sqllogin);
  8.             String sql_username = null;
  9.         String sql_password = null;
  10.         if(rs.next()){
  11.         sql_username = rs.getString("username");
  12.         sql_password = rs.getString("password");
  13.                
  14.         if(sql_username.equals(txt_username.getText())&&sql_password.equals(txt_passwd.getText())){
  15.                             JOptionPane.showMessageDialog(this, "Berhasil masuk");
  16.                 this.setVisible(false);
  17.         }else
  18.                 {
  19.                     JOptionPane.showMessageDialog(this, "USERNAME atau PASSWORD anda salah"," PERINGATAN ", JOptionPane.ERROR_MESSAGE);
  20.             }
  21.             }
  22.             else{
  23.                     JOptionPane.showMessageDialog(this, "USERNAME atau PASSWORD anda salah"," PERINGATAN ", JOptionPane.ERROR_MESSAGE);
  24.             }
  25.            
  26.              rs.close();
  27.              con.close();
  28.         }catch(SQLException e){
  29.             JOptionPane.showMessageDialog(null, "USERNAME atau PASSWORD  anda SALAH", "PESAN", JOptionPane.ERROR_MESSAGE);
  30.         }
  31.     }
  32.    
  33.     void Kosong(){
  34.        
  35.         if(txt_username.getText().equals("")){
  36.            JOptionPane.showMessageDialog(this, " USERNAME atau PASSWORD belum diisi", "PESAN", JOptionPane.ERROR_MESSAGE);
  37.         }else if(txt_passwd.getPassword().equals("")){
  38.            JOptionPane.showMessageDialog(this, " USERNAME atau PASSWORD belum diisi", "PESAN", JOptionPane.ERROR_MESSAGE);
  39.         }else{
  40.             Masuk();
  41.         }
  42.     }
Add Comment
Please, Sign In to add comment