Beranda > Komputer's > Membuat Login Menggunakan Database Java

Membuat Login Menggunakan Database Java

Form Login
Aktion Button Masuk
String user = txtUsername.getText();
String pass = txtPassword.getText();
if (user.equals("")) {
textAreaLogin.setText("Username masih kosong..");
} else if (pass.equals("")) {
textAreaLogin.setText("Password masih kosong..");
} else {
try {
String sqlLogin = "select * from pakar where username = '" + user + "'" + "and pass = '" + pass + "'";
koneksiObj.statement = koneksiObj.connection1.createStatement();
koneksiObj.result = koneksiObj.statement.executeQuery(sqlLogin);

int baris = 0;
while (koneksiObj.result.next()) {
baris = koneksiObj.result.getRow();
}
if (baris == 1) {
new ProgramPakar().setVisible(true);
dispose();
} else {

textAreaLogin.setText(“Login anda salah, periksa kembali”);
txtUsername.setText(“”);
txtPassword.setText(“”);
txtUsername.requestFocus();
// JOptionPane.showMessageDialog(null, “User Id atau Password Tidak Cocok\n ‘”+user+”‘\n'”+password+”‘”);

}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}

Iklan
Kategori:Komputer's
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: