private void cariobatKeyPressed(java.awt.event.KeyEvent evt) { try { String nm = cariobat.getText(); conn = (Connection) new konek().login(); statement = conn.createStatement(); MTObat.getDataVector().removeAllElements(); String sql = "select idobat, jenis, namaobat, keterangan from obat o, golongan g , satuanobat s WHERE o.idgolongan=g.idgolongan AND s.idsatuan=o.idsatuan AND namaobat like '%" + nm + "%'"; ResultSet rs = statement.executeQuery(sql); while (rs.next()) { Object[] data = {rs.getString("idobat"), rs.getString("jenis"), rs.getString("namaobat"), rs.getString("keterangan"),}; MTObat.addRow(data); } } catch (Exception e) { e.printStackTrace(); } }
Tidak ada komentar:
Posting Komentar