public void updateDokter(Dokter d, String idDokter) throws SQLException { try { PreparedStatement ps = (PreparedStatement) connection.prepareStatement(updateDokter); ps.setString(1, d.getNmDokter()); ps.setString(2, d.getIdSpesialis()); ps.setString(3, idDokter); ps.executeUpdate(); ps.close(); // JOptionPane.showMessageDialog(null, "Data dokter berhasil diubah!"); } catch (SQLException se) { // JOptionPane.showMessageDialog(null, se.getMessage(),"Update Dokter // Gagal!",JOptionPane.ERROR_MESSAGE); } }
public List getAllDokter() throws SQLException { try { List list = new ArrayList(); Statement s = (Statement) connection.createStatement(); ResultSet rs = s.executeQuery(getAllDokter); while (rs.next()) { Dokter d = new Dokter(); d.setIdDokter(rs.getString("id_dokter")); d.setNmDokter(rs.getString("nm_dokter")); d.setIdSpesialis(rs.getString("nm_spesialis")); list.add(d); } rs.close(); s.close(); return list; } catch (SQLException se) { JOptionPane.showMessageDialog( null, se.getMessage(), "Get All dokter gagal!", JOptionPane.ERROR_MESSAGE); return null; } }
public List getByIdSpesialis(String idSpesialis) throws SQLException { try { List list = new ArrayList(); PreparedStatement ps = (PreparedStatement) connection.prepareStatement(ambilNamaDokter); ps.setString(1, idSpesialis); ResultSet rs = ps.executeQuery(); while (rs.next()) { Dokter d = new Dokter(); d.setIdDokter(rs.getString("id_dokter")); d.setNmDokter(rs.getString("nm_dokter")); list.add(d); } rs.close(); ps.close(); return list; } catch (SQLException se) { JOptionPane.showMessageDialog( null, se.getMessage(), "Get Dokter By Id Spesialis Gagal!", JOptionPane.ERROR_MESSAGE); return null; } }