Advertisement
ajiperdana

contoh script login dengan Java

Nov 10th, 2015
3,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.             Connection con = koneksi.Koneksi();
  3.             String sql = "Select * from user where u_name = '" + jTextField1.getText().trim() + "'" + "and u_pass = '" + jTextField2.getText + "'";
  4.             Statement stat = con.createStatement();
  5.             ResultSet res = stat.executeQuery(sql);
  6.             if (res.next()) { //cek inputan, jika cocok maka akan dialihkan ke Form HalamanUtama()
  7.                 JOptionPane.showMessageDialog(null, "Anda Berhasil Login!", "Peringatan", JOptionPane.INFORMATION_MESSAGE);
  8.                 new HalamanUtama().setVisible(true);
  9.                 dispose(); //untuk menyembunyikan form ini
  10.             } else {
  11.                 JOptionPane.showMessageDialog(null, "Anda Gagal Login!", "Peringatan", JOptionPane.WARNING_MESSAGE);
  12.                 jTextField1.requestFocusInWindow();
  13.                 jTextField1.setText("");
  14.                 jTextField2.setText("");
  15.             }
  16.         } catch (Exception ex) {
  17.             System.out.println("kesalahan :" + ex.toString());
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement