Membuat Form Data Buku: TXTKD Txtjudul Cbkategori
Membuat Form Data Buku: TXTKD Txtjudul Cbkategori
Membuat Form Data Buku: TXTKD Txtjudul Cbkategori
txtkd
txtjudul
cbkategori
txtsinopsis
tabelbuku
package tampilan;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import koneksi.koneksi;
public formbuku() {
initComponents();
kosong();
aktif();
datatable();
}
2. Method Aktif
3. Method Kosong
4. Datatable
try {
String sql = "SELECT * FROM buku";
java.sql.Statement stat = conn.createStatement();
ResultSet hasil = stat.executeQuery(sql);
while (hasil.next()){
tabmode.addRow(new Object[]{
hasil.getString(1),
hasil.getString(2),
hasil.getString(3),
hasil.getString(4)
});
}
tabelbuku.setModel(tabmode);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Data Gagal Tampil" +e);
}
}
5. Tombol Simpan
stat.executeUpdate();
JOptionPane.showMessageDialog(null, "Data Berhasil Disimpan");
kosong ();
txtkd.requestFocus();
}
catch (SQLException e) {
JOptionPane.showMessageDialog(null, "Data Gagal Disimpan "+e);
}
datatable();
}
6. Tombol Ubah
stat.executeUpdate();
JOptionPane.showMessageDialog(null, "Data Berhasil Diubah");
kosong();
txtkd.requestFocus();
}
catch (SQLException e){
JOptionPane.showMessageDialog(null, "Data Gagal Diubah"+e);
}
datatable();
}
7. Tombol Hapus
8. Tombol Keluar
9. Tombol Batal
txtkd.setText(a);
txtjudul.setText(b);
cbkategori.setSelectedItem(c);
txtsinopsis.setText(d);
}