Professional Documents
Culture Documents
package pbo1;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import java.sql.DriverManager;
import pbo1.koneksi;
/**
* @author Wibowo
*/
public register() {
initComponents();
txID.setEnabled(false);
autonumber();
try{
Connection c = koneksi.getkoneksi();
Statement s = c.createStatement();
if (r.next()) {
if (ID.length()==1)
{Zero = "00";}
else if (ID.length()==2)
{Zero = "0";}
else if (ID.length()==3)
{Zero = "";}
}else{
txID.setText("AD001");
r.close();
s.close();
}catch(Exception e){
System.out.println("gagal");
String id = txID.getText().toString().trim();
if (!password.equals(conPassword)) {
} else {
try {
Connection c = koneksi.getkoneksi();
String sql = "INSERT INTO db_user (id, username, password) VALUES (?, ?, ?)";
p.setString(1, id);
p.setString(2, username);
p.setString(3, password);
if (affectedRows > 0) {
} else {
} catch (SQLException e) {
} finally {
this.dispose();
a.setVisible(true);
}
/**
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
*/
try {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
java.util.logging.Logger.getLogger(register.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(register.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(register.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
java.util.logging.Logger.getLogger(register.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
//</editor-fold>
java.awt.EventQueue.invokeLater(new Runnable() {
new register().setVisible(true);
});
}
Form Login
package pbo1;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
import pbo1.koneksi;
import pbo1.MenuUtama;
/**
*
* @author Wibowo
*/
public class login extends javax.swing.JFrame {
public login() {
initComponents();
}
if (r.next()) {
JOptionPane.showMessageDialog(null, "Login Berhasil");
this.dispose();
book1 menu = new book1(); // Ganti dengan nama class menuUtama yang sesuai
menu.setVisible(true);
} else {
JOptionPane.showMessageDialog(null, "Password atau username salah");
password.requestFocus();
}
} catch (SQLException e) {
System.out.println("Error: " + e.getMessage());
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
package pbo1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/* @author : Abi*/