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 getByIdDokter(String idDokter) throws SQLException { try { List list = new ArrayList(); PreparedStatement ps = (PreparedStatement) connection.prepareStatement(getByIdDokter); ps.setString(1, idDokter); ResultSet rs = ps.executeQuery(); 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(); ps.close(); return list; } catch (SQLException se) { JOptionPane.showMessageDialog( null, se.getMessage(), "Get Dokter By Id Gagal!", JOptionPane.ERROR_MESSAGE); return null; } }