| @@ -0,0 +1,35 @@ | |||||
| package de.uniluebeck.mi.projmi6.db; | |||||
| import de.uniluebeck.mi.projmi6.model.Patient; | |||||
| import java.sql.ResultSet; | |||||
| import java.sql.SQLException; | |||||
| import java.sql.Statement; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Created by nils on 15.11.2015. | |||||
| */ | |||||
| public class DBHandler { | |||||
| public static final String SELECT_ALL_PATIENTS = "SELECT * FROM `patient`"; | |||||
| public List<Patient> getAllPatients() throws SQLException { | |||||
| Statement statement = null; | |||||
| ResultSet rs = null; | |||||
| statement = MySqlConnFactory.getConnection().createStatement(); | |||||
| rs = statement.executeQuery(SELECT_ALL_PATIENTS); | |||||
| List<Patient> patients = new ArrayList<Patient>(); | |||||
| while (rs.next()) { | |||||
| Patient patient = new Patient(); | |||||
| patient.setPatID(rs.getInt("geburtsname")); | |||||
| patient.setVorname(rs.getString("vorname")); | |||||
| patient.setNachname(rs.getString("nachname")); | |||||
| patient.setGeburtsdatum(rs.getDate("geburtsdatum").toLocalDate()); | |||||
| } | |||||
| return patients; | |||||
| } | |||||
| } | |||||