Pages

Pages - Menu

Dokumentasi untuk memunculkan database di combobox

void initGol() {
        go.removeAllItems();

        Statement ste = null;
        ResultSet rse = null;

        try {
            konek k = new konek();
            conn = k.login();
            ste = conn.createStatement();
            String sql = "SELECT jenis from golongan order by jenis ASC";
            rse = ste.executeQuery(sql);
            while (rse.next()) {
                String no = rse.getString("jenis");
                go.addItem(no);
            }
            gol = go.getSelectedItem().toString();
        } catch (Exception e) {
            System.out.println(e);
        } finally {
            try {
                if (rse != null) {
                    rse.close();
                }
            } catch (SQLException e) {
            }
            try {
                if (ste != null) {
                    ste.close();
                }
            } catch (SQLException e) {
            }
        }
    }

Tidak ada komentar:

Posting Komentar