Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class crud extends javax.swing.JFrame {
- DefaultTableModel model;
- //declare koneksi disini
- private Connection koneksi;
- /**
- * Creates new form crud
- */
- public crud() {//Constructor
- initComponents();
- //instance koneksi di sini
- koneksi = DriverManager.getConnection("jdbc:mysql://localhost:3306/crud","root","");
- String []judul={"ID","NAMA","JENIS KELAMIN","ALAMAT"};
- model= new DefaultTableModel(judul, 0);
- jTable1.setModel(model);
- tampilkan();
- }
- private void tampilkan() {
- ...bla blaa
- //jd tinggal panggil koneksi di button dll, gak perlu di instance lg
- ResultSet rs = koneksi.createStatement().executeQuery("select * from datasiswa");
- ....bla blaaa
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement