Results 1 to 3 of 3
  1. #1
    gustio is offline Member
    Join Date
    Jun 2008
    Posts
    14
    Rep Power
    0

    Default [SOLVED] Update jTable with new data (especially Date value Format)

    Hi,
    - I make database application use postgresql as server and Netbeans 6.1 as Java IDE.
    - I can’t Update jTable with new data when I edit data (use [rubah] button) and saving its (with [simpan] button).
    - It is part of my program and data.
    I know that it is too long, I am sorry.
    -- I need help from you, thank you.

    -- Database: pegawai
    CREATE DATABASE pegawai
    ENCODING = 'UTF8';

    -- Table: pegawai
    -- DROP TABLE pegawai;
    CREATE TABLE pegawai
    ( nip VARCHAR(18) PRIMARY KEY,
    nama VARCHAR(50));

    -- Table: diklattempat
    CREATE TABLE diklattempat
    ( diklattempatid INTEGER PRIMARY KEY,
    diklattempat VARCHAR(40) UNIQUE);

    -- Table: pendidikaninstitusi
    CREATE TABLE pendidikaninstitusi
    ( pendidikaninstitusiid INTEGER PRIMARY KEY,
    pendidikaninstitusinama VARCHAR(55) UNIQUE,
    pendidikaninstitusilokasikode INTEGER REFERENCES diklattempat (diklattempatid));

    -- Table: pendidikaninstitusikepala
    CREATE TABLE pendidikaninstitusikepala
    ( pendidikaninstitusikepalaid INTEGER PRIMARY KEY,
    pendidikaninstitusikepala VARCHAR(50) UNIQUE);

    -- Table: pendidikantingkat
    CREATE TABLE pendidikantingkat
    ( pendidikantingkatid SMALLINT PRIMARY KEY,
    pendidikantingkat VARCHAR(20) UNIQUE);

    -- Table: pendidikan
    CREATE TABLE pendidikan
    ( pendidikanid INTEGER PRIMARY KEY,
    pendidikantingkatkode SMALLINT REFERENCES pendidikantingkat (pendidikantingkatid),
    pendidikannama VARCHAR(45) UNIQUE);

    -- Table: pendidikanriwayat
    CREATE TABLE pendidikanriwayat
    ( pendidikannip VARCHAR(18) REFERENCES pegawai (nip),
    pendidikankode INTEGER REFERENCES pendidikan (pendidikanid),
    pendidikaninstitusikode INTEGER REFERENCES pendidikaninstitusi (pendidikaninstitusiid),
    pendidikaninstitusikepalakode INTEGER REFERENCES pendidikaninstitusikepala (pendidikaninstitusikepalaid),
    pendidikanijazahnomor VARCHAR(40),
    pendidikanijazahtanggal DATE, PRIMARY KEY (pendidikannip, pendidikankode));



    --DATA
    INSERT INTO pegawai VALUES
    ('460023417', 'MUHAMMAD'),
    ('060023172', 'BAGIANTO'),
    ('010023417', 'GUSTIO'),
    ('460021317', 'MARUF');

    INSERT INTO diklattempat VALUES
    (1, 'JAKARTA'),
    (2, 'BANDUNG'),
    (3, 'YOGYAKARTA'),
    (4, 'LAMPUNG');

    INSERT INTO pendidikaninstitusi VALUES
    (1, 'UNIVERSITAS TERBUKA', 1),
    (2, 'INSTITUT TEKNOLOGI BANDUNG', 2),
    (3, 'UNIVERSITAS GADJAH MADA', 3),
    (4, 'UNIVERSITAS LAMPUNG', 4);


    INSERT INTO pendidikaninstitusikepala VALUES
    (1, 'MUHAJIR UTOMO'),
    (2, 'ICH. AMAL');

    INSERT INTO pendidikantingkat VALUES
    (1, 'SD'),
    (2, 'SLTP'),
    (3, 'SLTA'),
    (4, 'D-I'),
    (5, 'D-II'),
    (6, 'D-III'),
    (7, 'D-IV/S-1'),
    (8, 'Profesi'),
    (9, 'S-2'),
    (10, 'Spesialis 1'),
    (11, 'S-3'),
    (12, 'Spesialis 2');


    INSERT INTO pendidikan VALUES
    (1, 9, 'MAGISTER MANAJEMEN'),
    (2, 8, 'KEDOKTERAN UMUM'),
    (3, 7, 'S-1 SISTEM INFORMASI');


    INSERT INTO pendidikanriwayat VALUES
    ('460023417', 3, 3, 1, NULL, '2006-8-1'),
    ('060023172', 1, 1, 2, NULL, '2006-2-1'),
    ('010023417', 2, 1, 2, NULL, '2005-2-1'),
    ('460021317', 2, 1, 2, NULL, '2004-4-1');


    -- FUNCTION
    -- insert data ke dalam tabel pendidikan
    CREATE FUNCTION ipendidikan (INTEGER, INTEGER, VARCHAR) RETURNS void
    AS
    $BODY$
    BEGIN
    INSERT INTO pendidikan VALUES ($1, $2, $3);
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- insert data ke dalam tabel diklattempat
    CREATE FUNCTION idiklattempat (INTEGER, VARCHAR) RETURNS void
    AS
    $BODY$
    BEGIN
    INSERT INTO diklattempat VALUES ($1, $2);
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- insert data ke dalam tabel pendidikaninstitusi
    CREATE FUNCTION ipendidikaninstitusi (INTEGER, VARCHAR, INTEGER) RETURNS void
    AS
    $BODY$
    BEGIN
    INSERT INTO pendidikaninstitusi VALUES ($1, $2, $3);
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- insert data ke dalam tabel pendidikaninstitusikepala
    CREATE FUNCTION ipendidikaninstitusikepala (INTEGER, VARCHAR) RETURNS void
    AS
    $BODY$
    BEGIN
    INSERT INTO pendidikaninstitusikepala VALUES ($1, $2);
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- insert data ke dalam tabel pendidikanriwayat
    CREATE FUNCTION ipendidikanriwayat (VARCHAR, INTEGER, INTEGER, INTEGER, VARCHAR, DATE) RETURNS void
    AS
    $BODY$
    BEGIN
    INSERT INTO pendidikanriwayat VALUES ($1, $2, $3, $4, $5, $6);
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- update data ke dalam tabel pendidikanriwayat
    CREATE FUNCTION upendidikanriwayat (VARCHAR, INTEGER, INTEGER, INTEGER, VARCHAR, DATE) RETURNS void
    AS
    $BODY$
    BEGIN
    UPDATE pendidikanriwayat SET pendidikaninstitusikode = $3, pendidikaninstitusikepalakode = $4, pendidikanijazahnomor = $5, pendidikanijazahtanggal = $6 WHERE pendidikannip = $1 AND pendidikankode = $2;
    END;
    $BODY$
    LANGUAGE 'plpgsql';

    -- delete data dari tabel pendidikanriwayat
    CREATE FUNCTION dpendidikanriwayat (VARCHAR, INTEGER) RETURNS void
    AS
    $BODY$
    BEGIN
    DELETE FROM pendidikanriwayat WHERE pendidikannip = $1 AND pendidikankode = $2;
    END;
    $BODY$
    LANGUAGE 'plpgsql';



    /*
    * SimpegApp.java
    */

    package simpeg;

    import java.sql.DriverManager;
    import java.sql.Connection;
    import java.sql.Statement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;

    /**
    *
    * @author gustio
    */

    public class SimpegApp {
    Connection con = null;
    ResultSet rs = null;
    String perintahSQL;

    public SimpegApp() {
    String url="jdbc:postgresql://localhost:5432/pegawai";
    String user="postgres"; // change as postgresql user
    String pass="passpostgres"; // change with your password
    try {
    Class.forName("org.postgresql.Driver");
    con = DriverManager.getConnection(url,user,pass);
    }
    catch (ClassNotFoundException ex) {
    tampilkanPesan(ex.getMessage() + " tidak ditemukan ...", "Kesalahan tidak ada driver");
    System.exit(1);
    }
    catch (SQLException ex) {
    tampilkanPesan(ex.getMessage(), "Database Tidak Ada");
    System.exit(1);
    }
    }

    /**
    * Method untuk menjalankan query
    */
    public void eksekusiSQL() {
    try {
    Statement stmt = con.createStatement(rs.TYPE_SCROLL_SENSITIVE, rs.CONCUR_UPDATABLE);
    rs = stmt.executeQuery(perintahSQL);
    }
    catch (SQLException ex) {
    tampilkanPesan(perintahSQL + " " +ex.getMessage(), "Kesalahan SQL");
    }
    }

    /**
    * Method untuk menampilkan pesan
    */
    public void tampilkanPesan(String isiPesan, String judul) {
    JFrame frame = null;
    JOptionPane.showMessageDialog(frame, isiPesan, judul, JOptionPane.INFORMATION_MESSAGE);
    }
    }



    /*
    * SimpegCV.java
    *
    * Created on 10 Agustus 2008, 18:37
    */

    package simpeg;

    //import org.jdesktop.application.Action;
    import java.sql.SQLException;
    import java.util.Date;
    //import java.text.DateFormat;
    //import java.text.SimpleDateFormat;
    //import java.text.ParseException;
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.JTable.*;

    /**
    *
    * @author gustio
    */
    public class SimpegCV extends javax.swing.JFrame {

    private DefaultTableModel tbmPendidikan_K;
    public String sNIP;
    public final String[] bulan = {"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"};
    public String s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15;
    public int thn, bln, jtgl, adaCpns, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11;
    public int barisTabel = 1;
    public boolean adaId, tambah_K;
    public boolean btnR_K; public boolean btnT_K; public boolean btnS_K; public boolean btnH_K;

    SimpegApp bioData = new SimpegApp();
    Calendar kalendar = new GregorianCalendar();

    /** Creates new form SimpegCV */
    public SimpegCV() {
    initComponents();
    tableModelDef();
    initPegawai();
    allInputOff();
    getRootPane().setDefaultButton(btnCari);
    }

    private void tableModelDef() {
    //Pendidikan table model
    String[] columnNamesPendidikan = {"Tingkat Pendidikan", "Nama Pendidikan", "Institusi Pendidikan", "Tempat", "Nama Kepala Institusi", "STTB Nomor", "Tanggal"};
    tbmPendidikan_K = new DefaultTableModel(null, columnNamesPendidikan){
    public Class getColumnClass(int column) {
    Class returnValue;
    if ((column >= 0) && (column < getColumnCount())) {
    returnValue = getValueAt(0, column).getClass();
    } else {
    returnValue = Object.class;
    }
    return returnValue;
    }
    public boolean isCellEditable(int row, int col) {
    return false;
    }
    };
    tblPendidikan_K.setModel(tbmPendidikan_K);
    }

    private void initPegawai() {
    btnRubah.setEnabled(false);
    btnTambah.setEnabled(false);
    btnSimpan.setEnabled(false);
    btnHapus.setEnabled(false);
    //nip pegawai
    bioData.perintahSQL = "SELECT nip FROM pegawai WHERE kepegawaianstatuskode = 1 OR kepegawaianstatuskode = 2 ORDER BY nip";
    bioData.eksekusiSQL();
    cmbNIP_A.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbNIP_A.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL NIP: " + se.getMessage(), "NIP");
    }
    //Tahun-Bulan-Tanggal
    Calendar sekarang = Calendar.getInstance();
    int tahun = sekarang.get(sekarang.YEAR);
    cmbSTTBTahun_K.addItem("");
    int tampil = 53;
    for (int ulang = 0; ulang < tampil; ulang++) {
    cmbSTTBTahun_K.addItem(String.valueOf(tahun-ulang));
    }
    cmbSTTBBulan_K.addItem("");
    for (int ulang = 0; ulang < 12; ulang++) {
    cmbSTTBBulan_K.addItem(bulan[ulang]);
    }
    cmbSTTBTanggal_K.addItem("");
    //PendidikanInstitusi
    bioData.perintahSQL = "SELECT pendidikaninstitusinama FROM pendidikaninstitusi ORDER BY pendidikaninstitusiid";
    bioData.eksekusiSQL();
    cmbPendidikanInstitusi_K.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbPendidikanInstitusi_K.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanInstitusi: " + se.getMessage(), "PendidikanInstitusi");
    }
    //DiklatTempat
    bioData.perintahSQL = "SELECT diklattempat FROM diklattempat ORDER BY diklattempatid";
    bioData.eksekusiSQL();
    cmbPendidikanTempat_K.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbPendidikanTempat_K.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL DiklatTempat: " + se.getMessage(), "DiklatTempat");
    }
    //PendidikanInstitusiKepala
    bioData.perintahSQL = "SELECT pendidikaninstitusikepala FROM pendidikaninstitusikepala ORDER BY pendidikaninstitusikepalaid";
    bioData.eksekusiSQL();
    cmbPendidikanInstitusiKepala_K.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbPendidikanInstitusiKepala_K.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanInstitusiKepala: " + se.getMessage(), "PendidikanInstitusiKepala");
    }
    //PendidikanTingkat
    bioData.perintahSQL = "SELECT pendidikantingkat FROM pendidikantingkat ORDER BY pendidikantingkatid";
    bioData.eksekusiSQL();
    cmbPendidikanTingkat_K.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbPendidikanTingkat_K.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanTingkat: " + se.getMessage(), "PendidikanTingkat");
    }
    //Pendidikan
    cmbPendidikanNama_K.addItem((Object)new String(""));
    }

    private void pilih_K() {
    btnRubah.setEnabled(btnR_K);
    btnTambah.setEnabled(btnT_K);
    btnSimpan.setEnabled(btnS_K);
    btnHapus.setEnabled(btnH_K);
    }

    private void allInputOff() {
    inputOff_K();
    }

    private void inputOff_K() {
    cmbPendidikanTingkat_K.setEnabled(false);
    cmbPendidikanNama_K.setEnabled(false);
    cmbPendidikanInstitusi_K.setEnabled(false);
    cmbPendidikanTempat_K.setEnabled(false);
    cmbPendidikanInstitusiKepala_K.setEnabled(false);
    txtSTTBNomor_K.setEnabled(false);
    cmbSTTBTahun_K.setEnabled(false);
    cmbSTTBBulan_K.setEnabled(false);
    cmbSTTBTanggal_K.setEnabled(false);
    }

    private void inputOn_K() {
    cmbPendidikanTingkat_K.setEnabled(true);
    cmbPendidikanNama_K.setEnabled(true);
    cmbPendidikanInstitusi_K.setEnabled(true);
    cmbPendidikanTempat_K.setEnabled(true);
    cmbPendidikanInstitusiKepala_K.setEnabled(true);
    txtSTTBNomor_K.setEnabled(true);
    cmbSTTBTahun_K.setEnabled(true);
    cmbSTTBBulan_K.setEnabled(true);
    cmbSTTBTanggal_K.setEnabled(true);
    }

    private void kosong_K() {
    cmbPendidikanTingkat_K.setSelectedItem("");
    cmbPendidikanNama_K.setSelectedItem("");
    cmbPendidikanInstitusi_K.setSelectedItem("");
    cmbPendidikanTempat_K.setSelectedItem("");
    cmbPendidikanInstitusiKepala_K.setSelectedItem("") ;
    txtSTTBNomor_K.setText("");
    cmbSTTBTahun_K.setSelectedItem("");
    cmbSTTBBulan_K.setSelectedItem("");
    cmbSTTBTanggal_K.setSelectedItem("");
    }

    // @Action
    public void cariPegawai() {
    allInputOff();
    btnR_K = true; btnT_K = true; btnS_K = false; btnH_K = false; pilih_K();
    kosong_K();
    sNIP = String.valueOf(cmbNIP_A.getSelectedItem());
    int jmlBaris = tbmPendidikan_K.getRowCount();
    for (int hapus = 0; hapus < jmlBaris; hapus++)
    tbmPendidikan_K.removeRow(0);
    bioData.perintahSQL = "SELECT pt.pendidikantingkat, p.pendidikannama, pi.pendidikaninstitusinama, d.diklattempat, pk.pendidikaninstitusikepala, pr.pendidikanijazahnomor, pr.pendidikanijazahtanggal " +
    "FROM ((((pendidikanriwayat pr LEFT JOIN pendidikan p ON pr.pendidikankode = p.pendidikanid) LEFT JOIN pendidikantingkat pt ON p.pendidikantingkatkode = pt.pendidikantingkatid) LEFT JOIN pendidikaninstitusi pi ON pr.pendidikaninstitusikode = pi.pendidikaninstitusiid) LEFT JOIN diklattempat d ON pi.pendidikaninstitusilokasikode = d.diklattempatid) LEFT JOIN pendidikaninstitusikepala pk ON pr.pendidikaninstitusikepalakode = pk.pendidikaninstitusikepalaid " +
    "WHERE pr.pendidikannip = \'" + sNIP + "\'";
    bioData.eksekusiSQL();
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    Object f2 = (Object)bioData.rs.getString(2);
    Object f3 = (Object)bioData.rs.getString(3);
    if (f3 == null)
    f3 = (Object)new String("");
    Object f4 = (Object)bioData.rs.getString(4);
    if (f4 == null)
    f4 = (Object)new String("");
    Object f5 = (Object)bioData.rs.getString(5);
    if (f5 == null)
    f5 = (Object)new String("");
    Object f6 = (Object)bioData.rs.getString(6);
    if (f6 == null)
    f6 = (Object)new String("");
    Object f7 = (Object)bioData.rs.getDate(7);
    if (f7 == null)
    f7 = (Object)new String("");
    Object[] datap = {f1, f2, f3, f4, f5, f6, f7};
    tbmPendidikan_K.addRow(datap);
    }
    if (tbmPendidikan_K.getRowCount() != 0) {
    bioData.rs.last();
    s2 = bioData.rs.getString(2);
    cmbPendidikanInstitusi_K.setSelectedItem(bioData.r s.getString(3));
    cmbPendidikanTempat_K.setSelectedItem(bioData.rs.g etString(4));
    cmbPendidikanInstitusiKepala_K.setSelectedItem(bio Data.rs.getString(5));
    txtSTTBNomor_K.setText(bioData.rs.getString(6));
    Date tglSTTB = bioData.rs.getDate(7);
    if (tglSTTB == null) {
    cmbSTTBTahun_K.setSelectedItem("");
    cmbSTTBBulan_K.setSelectedItem("");
    cmbSTTBTanggal_K.setSelectedItem("");
    } else {
    kalendar.setTime(tglSTTB);
    thn = kalendar.get(Calendar.YEAR);
    bln = kalendar.get(Calendar.MONTH);
    int tgl = kalendar.get(Calendar.DATE);
    cmbSTTBTahun_K.setSelectedItem(String.valueOf(thn) );
    cmbSTTBBulan_K.setSelectedItem(bulan[bln]);
    cmbSTTBTanggal_K.setSelectedItem(String.valueOf(tg l));
    cmbPendidikanTingkat_K.setSelectedItem(bioData.rs. getString(1));
    cmbPendidikanNama_K.setSelectedItem(s2);
    }
    } else {
    btnR_K = false;
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanRiwayat: " + se.getMessage(), "PendidikanRiwayat");
    }
    }

    // @Action
    public void rubah() {
    btnR_K = false; btnT_K = false; btnS_K = true; btnH_K = false; pilih_K(); inputOn_K(); tambah_K = false;
    tambah_K = false;
    txtSTTBNomor_K.requestFocus();
    }

    // @Action
    public void tambah() {
    btnR_K = false; btnT_K = false; btnS_K = true; btnH_K = false; pilih_K(); inputOn_K(); kosong_K();
    tambah_K = true;
    }

    // @Action
    public void simpan() {
    btnR_K = true; btnT_K = true; btnS_K = false; btnH_K = false; pilih_K(); inputOff_K();
    s1 = String.valueOf(cmbPendidikanTingkat_K.getSelectedI tem());
    s2 = ", \'" + cmbPendidikanNama_K.getSelectedItem() + "\'";
    s3 = ", \'" + cmbPendidikanInstitusi_K.getSelectedItem() + "\'";
    if (s3.equals(", \'\'") || s3.equals(", \'null\'"))
    s3 = ", null";
    s4 = ", \'" + cmbPendidikanTempat_K.getSelectedItem() + "\'";
    if (s4.equals(", \'\'") || s4.equals(", \'null\'"))
    s4 = ", null";
    s5 = ", \'" + cmbPendidikanInstitusiKepala_K.getSelectedItem() + "\'";
    if (s5.equals(", \'\'") || s5.equals(", \'null\'"))
    s5 = ", null";
    s6 = ", \'" + txtSTTBNomor_K.getText() + "\'";
    if (s6.equals(", \'\'"))
    s6 = ", null";
    s7 = ", \'" + String.valueOf(cmbSTTBTahun_K.getSelectedItem()) + "-" + String.valueOf(cmbSTTBBulan_K.getSelectedIndex()) + "-" + String.valueOf(cmbSTTBTanggal_K.getSelectedItem()) + "\'";
    bioData.tampilkanPesan("s4 : " + String.valueOf(cmbPendidikanTempat_K.getSelectedIt em()) + " s5 : " + String.valueOf(cmbPendidikanInstitusiKepala_K.getS electedItem()) + " s2 : " + s2 + " s3 : " + s3 + " s6 : " + s6 + " s7 : " + s7, "Menyebalkan");
    Object f1 = cmbPendidikanTingkat_K.getSelectedItem();
    Object f2 = cmbPendidikanNama_K.getSelectedItem();
    Object f3 = cmbPendidikanInstitusi_K.getSelectedItem();
    Object f4 = cmbPendidikanTempat_K.getSelectedItem();
    Object f5 = cmbPendidikanInstitusiKepala_K.getSelectedItem();
    Object f6 = (Object)txtSTTBNomor_K.getText();
    Object f7 = (Object)String.valueOf(cmbSTTBTahun_K.getSelectedI tem()) + "-" + String.valueOf(cmbSTTBBulan_K.getSelectedIndex()) + "-" + String.valueOf(cmbSTTBTanggal_K.getSelectedItem()) ;
    if ((String.valueOf(cmbPendidikanTingkat_K).equals("" )) ||
    (String.valueOf(cmbPendidikanNama_K.getSelectedIte m()).equals("")) ||
    (s7.equals(", \'-0-\'"))) {
    bioData.tampilkanPesan("Tingkat Pendidikan, Nama Pendidikan, dan Tanggal STTB tidak boleh kosong!", "Pendidikan");
    } else {
    bioData.perintahSQL = "SELECT pendidikantingkatid FROM pendidikantingkat WHERE pendidikantingkat = \'" + s1 + "\'";
    bioData.eksekusiSQL();
    try {
    bioData.rs.last();
    i1 = bioData.rs.getInt(1);
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL TingkatPendidikan_K: " + se.getMessage(), "TingkatPendidikan_K");
    }
    s1 = ", " + String.valueOf(i1);
    bioData.perintahSQL = "SELECT pendidikanid FROM pendidikan WHERE pendidikantingkatkode = " + String.valueOf(i1) + " AND pendidikannama = \'" + cmbPendidikanNama_K.getSelectedItem() + "\'";
    bioData.eksekusiSQL();
    try {
    if (bioData.rs.next()) {
    i2 = bioData.rs.getInt(1);
    adaId = true;
    } else {
    adaId= false;
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL Pendidikan_K: " + se.getMessage(), "Pendidikan_K");
    }
    if (!adaId) {
    bioData.perintahSQL = "SELECT MAX(pendidikanid) FROM pendidikan";
    bioData.eksekusiSQL();
    try {
    bioData.rs.first();
    i2 = bioData.rs.getInt(1) + 1;
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL IdPendidikan_K: " + se.getMessage(), "IdPendidikan_K");
    }
    bioData.perintahSQL = "SELECT ipendidikan(" + String.valueOf(i2) + s1 + s2 + ")";
    bioData.eksekusiSQL();
    adaId = true;
    }
    s2 = ", " + String.valueOf(i2);
    if (!s4.equals(", null")) {
    bioData.perintahSQL = "SELECT diklattempatid FROM diklattempat WHERE diklattempat = \'" + String.valueOf(cmbPendidikanTempat_K.getSelectedIt em()) + "\'";
    bioData.eksekusiSQL();
    try {
    if (bioData.rs.next()) {
    i3 = bioData.rs.getInt(1);
    adaId = true;
    } else {
    adaId= false;
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL TempatPendidikan_K: " + se.getMessage(), "TempatPendidikan_K");
    }
    if (!adaId) {
    bioData.perintahSQL = "SELECT MAX(diklattempatid) FROM diklattempat";
    bioData.eksekusiSQL();
    try {
    bioData.rs.first();
    i3 = bioData.rs.getInt(1) + 1;
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL IdTempatPendidikan_K: " + se.getMessage(), "IdTempatPendidikan_K");
    }
    bioData.perintahSQL = "SELECT idiklattempat(" + String.valueOf(i3) + s4 + ")";
    bioData.eksekusiSQL();
    adaId = true;
    }
    s4 = ", " + String.valueOf(i3);
    }
    if (!s3.equals(", null")) {
    bioData.perintahSQL = "SELECT pendidikaninstitusiid FROM pendidikaninstitusi WHERE pendidikaninstitusinama = \'" + String.valueOf(cmbPendidikanInstitusi_K.getSelecte dItem()) + "\'";
    bioData.eksekusiSQL();
    try {
    if (bioData.rs.next()) {
    i4 = bioData.rs.getInt(1);
    adaId = true;
    } else {
    adaId= false;
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanInstitusi_K: " + se.getMessage(), "PendidikanInstitusi_K");
    }
    if (!adaId) {
    bioData.perintahSQL = "SELECT MAX(pendidikaninstitusiid) FROM pendidikaninstitusi";
    bioData.eksekusiSQL();
    try {
    bioData.rs.first();
    i4 = bioData.rs.getInt(1) + 1;
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL IdPendidikanInstitusi_K: " + se.getMessage(), "IdPendidikanInstitusi_K");
    }
    bioData.perintahSQL = "SELECT ipendidikaninstitusi(" + String.valueOf(i5) + s3 + s4 + ")";
    bioData.eksekusiSQL();
    adaId = true;
    }
    s3 = ", " + String.valueOf(i4);
    }
    if (!s5.equals(", null")) {
    bioData.perintahSQL = "SELECT pendidikaninstitusikepalaid FROM pendidikaninstitusikepala WHERE pendidikaninstitusikepala = \'" + String.valueOf(cmbPendidikanInstitusiKepala_K.getS electedItem()) + "\'";
    bioData.eksekusiSQL();
    try {
    if (bioData.rs.next()) {
    i6 = bioData.rs.getInt(1);
    adaId = true;
    } else {
    adaId= false;
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanInstitusiKepala_K: " + se.getMessage(), "PendidikanInstitusiKepala_K");
    }
    if (!adaId) {
    bioData.perintahSQL = "SELECT MAX(pendidikaninstitusikepalaid) FROM pendidikaninstitusikepala";
    bioData.eksekusiSQL();
    try {
    bioData.rs.first();
    i6 = bioData.rs.getInt(1) + 1;
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL IdPendidikanInstitusiKepala_K: " + se.getMessage(), "IdPendidikanInstitusiKepala_K");
    }
    bioData.perintahSQL = "SELECT ipendidikaninstitusikepala(" + String.valueOf(i6) + s5 + ")";
    bioData.eksekusiSQL();
    adaId = true;
    }
    s5 = ", " + String.valueOf(i6);
    }
    if (tambah_K) {
    bioData.perintahSQL = "SELECT ipendidikanriwayat(\'" + sNIP + "\'" + s2 + s3 + s5 + s6 + s7 + ")";
    bioData.eksekusiSQL();
    Object[] datap = {f1, f2, f3, f4, f5, f6, f7};
    tbmPendidikan_K.addRow(datap);
    tambah_K = false;
    } else {
    bioData.perintahSQL = "SELECT upendidikanriwayat(\'" + sNIP + "\'" + s2 + s3 + s5 + s6 + s7 + ")";
    bioData.eksekusiSQL();
    if (!(f1.equals(tblPendidikan_K.getValueAt(barisTabel ,0)) || f2.equals(tblPendidikan_K.getValueAt(barisTabel,1) ))) {
    int baris = 0;
    while (!f1.equals(tblPendidikan_K.getValueAt(baris,0))) {
    baris++;
    }
    while (!f2.equals(tblPendidikan_K.getValueAt(baris,1))) {
    baris++;
    }
    barisTabel = baris;
    }
    tblPendidikan_K.setValueAt(f3, barisTabel, 2);
    tblPendidikan_K.setValueAt(f4, barisTabel, 3);
    tblPendidikan_K.setValueAt(f5, barisTabel, 4);
    tblPendidikan_K.setValueAt(f6, barisTabel, 5);
    tblPendidikan_K.setValueAt(f7, barisTabel, 6);
    tblPendidikan_K.clearSelection();
    }
    }
    }

    // @Action
    public void hapus() {
    //do delete data
    }

    // @Action
    public void batal() {
    //do cancel
    }

    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jScrollPane1 = new javax.swing.JScrollPane();
    tblPendidikan_K = new javax.swing.JTable();
    jLabel1 = new javax.swing.JLabel();
    cmbNIP_A = new javax.swing.JComboBox();
    jPanel1 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    cmbPendidikanTingkat_K = new javax.swing.JComboBox();
    cmbPendidikanNama_K = new javax.swing.JComboBox();
    cmbPendidikanInstitusi_K = new javax.swing.JComboBox();
    cmbPendidikanInstitusiKepala_K = new javax.swing.JComboBox();
    txtSTTBNomor_K = new javax.swing.JTextField();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    cmbPendidikanTempat_K = new javax.swing.JComboBox();
    cmbSTTBTahun_K = new javax.swing.JComboBox();
    cmbSTTBBulan_K = new javax.swing.JComboBox();
    cmbSTTBTanggal_K = new javax.swing.JComboBox();
    jPanel3 = new javax.swing.JPanel();
    btnCari = new javax.swing.JButton();
    btnRubah = new javax.swing.JButton();
    btnTambah = new javax.swing.JButton();
    btnSimpan = new javax.swing.JButton();
    btnHapus = new javax.swing.JButton();
    btnBatal = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);
    setTitle("Sistem Informasi");

    jScrollPane1.setName("jScrollPane1"); // NOI18N

    tblPendidikan_K.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
    "Tingkat Pendidikan", "Nama Pendidikan", "Institusi Pendidikan", "Tempat", "Nama Kepala Institusi", "STTB Nomor", "Tanggal"
    }
    ));
    tblPendidikan_K.setName("tblPendidikan_K"); // NOI18N
    jScrollPane1.setViewportView(tblPendidikan_K);

    jLabel1.setText("NIP");
    jLabel1.setName("jLabel1"); // NOI18N

    cmbNIP_A.setEditable(true);
    cmbNIP_A.setName("cmbNIP_A"); // NOI18N

    jPanel1.setBorder(javax.swing.BorderFactory.create EtchedBorder());
    jPanel1.setName("jPanel1"); // NOI18N

    jLabel2.setText("1. Pendidikan");
    jLabel2.setName("jLabel2"); // NOI18N

    jLabel3.setText("2. Institusi Pendidikan");
    jLabel3.setName("jLabel3"); // NOI18N

    jLabel4.setText("3. Kepala Sekolah/Rektor");
    jLabel4.setName("jLabel4"); // NOI18N

    jLabel5.setText("4. STTB");
    jLabel5.setName("jLabel5"); // NOI18N

    cmbPendidikanTingkat_K.setName("cmbPendidikanTingk at_K"); // NOI18N
    cmbPendidikanTingkat_K.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    cmbPendidikanTingkat_KActionPerformed(evt);
    }
    });

    cmbPendidikanNama_K.setName("cmbPendidikanNama_K") ; // NOI18N

    cmbPendidikanInstitusi_K.setName("cmbPendidikanIns titusi_K"); // NOI18N

    cmbPendidikanInstitusiKepala_K.setName("cmbPendidi kanInstitusiKepala_K"); // NOI18N

    txtSTTBNomor_K.setName("txtSTTBNomor_K"); // NOI18N

    jLabel7.setText("Nomor");
    jLabel7.setName("jLabel7"); // NOI18N

    jLabel8.setText("Tanggal");
    jLabel8.setName("jLabel8"); // NOI18N

    jLabel6.setText("Tempat");
    jLabel6.setName("jLabel6"); // NOI18N

    cmbPendidikanTempat_K.setName("cmbPendidikanTempat _K"); // NOI18N

    cmbSTTBTahun_K.setName("cmbSTTBTahun_K"); // NOI18N
    cmbSTTBTahun_K.addContainerListener(new java.awt.event.ContainerAdapter() {
    public void componentRemoved(java.awt.event.ContainerEvent evt) {
    cmbSTTBTahun_KComponentRemoved(evt);
    }
    });

    cmbSTTBBulan_K.setName("cmbSTTBBulan_K"); // NOI18N
    cmbSTTBBulan_K.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    cmbSTTBBulan_KActionPerformed(evt);
    }
    });

    cmbSTTBTanggal_K.setName("cmbSTTBTanggal_K"); // NOI18N

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addComponent(jLabel2)
    .addComponent(jLabel3)
    .addComponent(jLabel4))
    .addGap(66, 66, 66)
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addComponent(cmbPendidikanTingkat_K, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(cmbPendidikanNama_K, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addComponent(cmbPendidikanInstitusi_K, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jLabel6)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(cmbPendidikanTempat_K, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addComponent(cmbPendidikanInstitusiKepala_K, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addComponent(jLabel7)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(txtSTTBNomor_K, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jLabel8)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(cmbSTTBTahun_K, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(cmbSTTBBulan_K, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(cmbSTTBTanggal_K, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))
    .addComponent(jLabel5))
    .addContainerGap(26, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(cmbPendidikanTingkat_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(cmbPendidikanNama_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel3)
    .addComponent(cmbPendidikanInstitusi_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel6)
    .addComponent(cmbPendidikanTempat_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel4)
    .addComponent(cmbPendidikanInstitusiKepala_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel5)
    .addComponent(jLabel7)
    .addComponent(txtSTTBNomor_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jLabel8)
    .addComponent(cmbSTTBBulan_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(cmbSTTBTanggal_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(cmbSTTBTahun_K, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(21, Short.MAX_VALUE))
    );

    jPanel3.setBorder(javax.swing.BorderFactory.create EtchedBorder());
    jPanel3.setName("jPanel3"); // NOI18N

    btnCari.setText("Cari");
    btnCari.setName("btnCari"); // NOI18N
    btnCari.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnCariMouseClicked(evt);
    }
    });

    btnRubah.setText("Rubah");
    btnRubah.setName("btnRubah"); // NOI18N
    btnRubah.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnRubahMouseClicked(evt);
    }
    });

    btnTambah.setText("Tambah");
    btnTambah.setName("btnTambah"); // NOI18N
    btnTambah.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnTambahMouseClicked(evt);
    }
    });

    btnSimpan.setText("Simpan");
    btnSimpan.setName("btnSimpan"); // NOI18N

    btnHapus.setText("Hapus");
    btnHapus.setName("btnHapus"); // NOI18N
    btnHapus.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnHapusMouseClicked(evt);
    }
    });

    btnBatal.setText("Batal");
    btnBatal.setName("btnBatal"); // NOI18N
    btnBatal.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnBatalMouseClicked(evt);
    }
    });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
    jPanel3Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel3Layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(btnCari)
    .addGap(18, 18, 18)
    .addComponent(btnRubah)
    .addGap(18, 18, 18)
    .addComponent(btnTambah)
    .addGap(18, 18, 18)
    .addComponent(btnSimpan)
    .addGap(18, 18, 18)
    .addComponent(btnHapus)
    .addGap(18, 18, 18)
    .addComponent(btnBatal)
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE))
    );
    jPanel3Layout.setVerticalGroup(
    jPanel3Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel3Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
    .addComponent(btnCari)
    .addComponent(btnRubah)
    .addComponent(btnTambah)
    .addComponent(btnSimpan)
    .addComponent(btnHapus)
    .addComponent(btnBatal))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(40, 40, 40)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.LEADING, false)
    .addGroup(layout.createSequentialGroup()
    .addGap(21, 21, 21)
    .addComponent(jLabel1)
    .addGap(159, 159, 159)
    .addComponent(cmbNIP_A, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 376, Short.MAX_VALUE))
    .addComponent(jScrollPane1)
    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(20, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, layout.createSequentialGroup()
    .addGap(16, 16, 16)
    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 91, Short.MAX_VALUE)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jLabel1)
    .addComponent(cmbNIP_A, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(18, 18, 18)
    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(152, 152, 152))
    );

    pack();
    }// </editor-fold>

    private void cmbPendidikanTingkat_KActionPerformed(java.awt.eve nt.ActionEvent evt) {
    pendidikanTingkat_K();
    }

    private void cmbSTTBBulan_KActionPerformed(java.awt.event.Actio nEvent evt) {
    sTTBTanggal_K();
    }

    private void cmbSTTBTahun_KComponentRemoved(java.awt.event.Cont ainerEvent evt) {
    if (!String.valueOf(cmbSTTBTahun_K.getSelectedItem()) .equals("")) {
    thn = Integer.parseInt(String.valueOf(cmbSTTBTahun_K.get SelectedItem()));
    } else {
    bioData.tampilkanPesan("Pilih Tahun terlebih dahulu!", "Tahun Kosong");
    }
    sTTBTanggal_K();
    }

    private void btnCariMouseClicked(java.awt.event.MouseEvent evt) {
    cariPegawai();
    }

    private void btnRubahMouseClicked(java.awt.event.MouseEvent evt) {
    rubah();
    }

    private void btnTambahMouseClicked(java.awt.event.MouseEvent evt) {
    tambah();
    }

    private void btnHapusMouseClicked(java.awt.event.MouseEvent evt) {
    hapus();
    }

    private void btnBatalMouseClicked(java.awt.event.MouseEvent evt) {
    batal();
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new SimpegCV().setVisible(true);
    }
    });
    }

    private void pendidikanTingkat_K() {
    if (!cmbPendidikanTingkat_K.getSelectedItem().equals( "")) {
    bioData.perintahSQL = "SELECT pendidikantingkatid FROM pendidikantingkat WHERE pendidikantingkat = \'" + String.valueOf(cmbPendidikanTingkat_K.getSelectedI tem()) + "\'";
    bioData.eksekusiSQL();
    try {
    while (bioData.rs.next()) {
    s1 = bioData.rs.getString(1); //aslinya integer, tapi dilangsungkan saja karena diambil dari recordset
    }
    bioData.rs.close();
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL PendidikanTingkat: " + se.getMessage(), "PendidikanTingkat");
    }
    bioData.perintahSQL = "SELECT pendidikannama FROM pendidikan WHERE pendidikantingkatkode = " + s1;
    bioData.eksekusiSQL();
    cmbPendidikanNama_K.removeAllItems();
    cmbPendidikanNama_K.addItem((Object)new String(""));
    try {
    while (bioData.rs.next()) {
    Object f1 = (Object)bioData.rs.getString(1);
    cmbPendidikanNama_K.addItem(f1);
    }
    }
    catch (SQLException se ) {
    bioData.tampilkanPesan("SQL Pendidikan: " + se.getMessage(), "Pendidikan");
    }
    }
    }

    private void sTTBTanggal_K() {
    if (!String.valueOf(cmbSTTBBulan_K.getSelectedItem()) .equals("")) {
    bln = cmbSTTBBulan_K.getSelectedIndex();
    jtglBln();
    String stgl = String.valueOf(cmbSTTBTanggal_K.getSelectedItem()) ;
    cmbSTTBTanggal_K.removeAllItems();
    cmbSTTBTanggal_K.addItem("");
    for (int ulang = 1; ulang <= jtgl; ulang++)
    cmbSTTBTanggal_K.addItem(String.valueOf(ulang));
    cmbSTTBTanggal_K.setSelectedItem(stgl);
    }
    }

    public void jtglBln() {
    if (bln == 2) {
    if ((thn%4 == 0) && ((thn%100 != 0) || (thn%400 == 0)))
    jtgl = 29;
    else
    jtgl = 28;
    } else if (bln == 4 || bln == 6 || bln == 9 || bln == 11) {
    jtgl = 30;
    } else {
    jtgl = 31;
    }
    }

    // Variables declaration - do not modify
    private javax.swing.JButton btnBatal;
    private javax.swing.JButton btnCari;
    private javax.swing.JButton btnHapus;
    private javax.swing.JButton btnRubah;
    private javax.swing.JButton btnSimpan;
    private javax.swing.JButton btnTambah;
    private javax.swing.JComboBox cmbNIP_A;
    private javax.swing.JComboBox cmbPendidikanInstitusiKepala_K;
    private javax.swing.JComboBox cmbPendidikanInstitusi_K;
    private javax.swing.JComboBox cmbPendidikanNama_K;
    private javax.swing.JComboBox cmbPendidikanTempat_K;
    private javax.swing.JComboBox cmbPendidikanTingkat_K;
    private javax.swing.JComboBox cmbSTTBBulan_K;
    private javax.swing.JComboBox cmbSTTBTahun_K;
    private javax.swing.JComboBox cmbSTTBTanggal_K;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable tblPendidikan_K;
    private javax.swing.JTextField txtSTTBNomor_K;
    // End of variables declaration

    }

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    doesn't it update the database table fields or JTable itself?

  3. #3
    gustio is offline Member
    Join Date
    Jun 2008
    Posts
    14
    Rep Power
    0

    Default

    - doesn't update jTable only.

    Sory:
    - I miss this for my code before:
    private void btnSimpanMouseClicked(java.awt.event.MouseEvent evt) {
    simpan();
    }
    - and initComponents():
    btnSimpan.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(java.awt.event.MouseEvent evt) {
    btnSimpanMouseClicked(evt);
    }
    });
    - I change my code to:
    + At simpan(), I add:
    if (f3 == null)
    f3 = (Object)String.valueOf("");
    if (f4 == null)
    f4 = (Object)String.valueOf("");
    if (f5 == null)
    f5 = (Object)String.valueOf("");
    + Table can’t update cause index out of bond, I set barisTabel = 1. Change it to barisTabel = 0, solve the problem.

    - But, Can I get better than I did?

    Salam.

Similar Threads

  1. How to update data for a JPA many-to-many relationship?
    By abhijit.sarkar in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 11-04-2008, 08:48 AM
  2. How to format the date in particular pattern
    By Java Tip in forum java.text
    Replies: 0
    Last Post: 04-04-2008, 02:35 PM
  3. How to format the date in particular pattern
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 09:28 PM
  4. Date format display in CSV file after exporting
    By latha in forum Advanced Java
    Replies: 0
    Last Post: 08-03-2007, 08:09 AM
  5. problems with Date format
    By tommy in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •