diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java index 90d2858..8715bb2 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java @@ -130,7 +130,7 @@ public class DBHandler { * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. */ public static List getAllPatients() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_PATIENTS); List patients = new ArrayList<>(); @@ -179,7 +179,7 @@ public class DBHandler { // TODO: Never used. public static Patient getPatient(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_PATIENT_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_PATIENT_BY_ID); ResultSet rs; statement.setInt(1, id); rs = statement.executeQuery(); @@ -198,9 +198,9 @@ public class DBHandler { public static void setPatient(Patient patient, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_PATIENT); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_PATIENT); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_PATIENT); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_PATIENT); } statement.setString(1, patient.getCave()); // CAVE @@ -238,7 +238,7 @@ public class DBHandler { } public static List getAllStationen() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_STATIONEN); List stationen = new ArrayList<>(); @@ -268,7 +268,7 @@ public class DBHandler { } public static List getStationsUebersichtsItems(String station) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATUBERITEMS_BY_STATION); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_STATUBERITEMS_BY_STATION); statement.setString(1, station); ResultSet rs = statement.executeQuery(); @@ -296,7 +296,7 @@ public class DBHandler { } public static List getStationsHistorieByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_STATHIST_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -327,7 +327,7 @@ public class DBHandler { } public static List getFaelleByPatID(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_FAELLE_BY_PATID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_FAELLE_BY_PATID); statement.setInt(1, id); ResultSet rs = statement.executeQuery(); @@ -381,9 +381,9 @@ public class DBHandler { public static void setFall(Fall fall, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_FALL); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_FALL); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_FALL); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_FALL); } if (fall.getAufnahmeDatum() != null) { @@ -455,7 +455,7 @@ public class DBHandler { } private static Diagnose getDiagnose(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_ID); statement.setInt(1, id); ResultSet rs = statement.executeQuery(); @@ -493,7 +493,7 @@ public class DBHandler { } public static List getAllIcd10Codes() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_ICD10CODES); List icd10codes = new ArrayList<>(); @@ -505,7 +505,7 @@ public class DBHandler { } private static Icd10Code getIcd10Code(String code, int version) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_ICD10CODE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_ICD10CODE_BY_ID); ResultSet rs; statement.setString(1, code); statement.setInt(2, version); @@ -531,7 +531,7 @@ public class DBHandler { } public static List getAllOpsCodes() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_OPSCODES); List opscodes = new ArrayList<>(); @@ -543,7 +543,7 @@ public class DBHandler { } private static OpsCode getOpsCode(String code, int version) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_OPSCODE_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_OPSCODE_BY_ID); ResultSet rs; statement.setString(1, code); statement.setInt(2, version); @@ -569,7 +569,7 @@ public class DBHandler { } public static List getAllMitarbeiter() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_MITARBEITER); List mitarbeiters = new ArrayList<>(); @@ -581,7 +581,7 @@ public class DBHandler { } private static Mitarbeiter getMitarbeiter(int id) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_MITARBEITER_BY_ID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_MITARBEITER_BY_ID); ResultSet rs; statement.setInt(1, id); rs = statement.executeQuery(); @@ -614,7 +614,7 @@ public class DBHandler { * @throws SQLException wenn Fehler bei der SQL Verarbeitung auftreten. */ public static List getUntersuchungByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_UNTERS_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_UNTERS_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -649,9 +649,9 @@ public class DBHandler { public static void setUntersuchung(Untersuchung untersuchung, int mitarbid, boolean isUpdate) throws SQLException { PreparedStatement statement; if (isUpdate) { - statement = MySqlConnFactory.getConnection().prepareStatement(UPDATE_UNTERSUCHUNG); + statement = MySqlConnectionFactory.getConnection().prepareStatement(UPDATE_UNTERSUCHUNG); } else { - statement = MySqlConnFactory.getConnection().prepareStatement(INSERT_UNTERSUCHUNG); + statement = MySqlConnectionFactory.getConnection().prepareStatement(INSERT_UNTERSUCHUNG); } statement.setInt(1, untersuchung.getDurchfuehrenderArzt().getMitarbID()); // DurchfuehrenderArzt @@ -669,7 +669,7 @@ public class DBHandler { } public static List getDiagnosenByFall(Fall fall) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_FALLID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_DIAGNOSE_BY_FALLID); statement.setInt(1, fall.getFallID()); ResultSet rs = statement.executeQuery(); @@ -682,7 +682,7 @@ public class DBHandler { } public static List getAllKassen() throws SQLException { - Statement statement = MySqlConnFactory.getConnection().createStatement(); + Statement statement = MySqlConnectionFactory.getConnection().createStatement(); ResultSet rs = statement.executeQuery(SELECT_ALL_KASSEN); List kassen = new ArrayList<>(); @@ -694,7 +694,7 @@ public class DBHandler { } private static Kasse getKasse(int kassenid) throws SQLException { - PreparedStatement statement = MySqlConnFactory.getConnection().prepareStatement(SELECT_KASSE_BY_KASSENID); + PreparedStatement statement = MySqlConnectionFactory.getConnection().prepareStatement(SELECT_KASSE_BY_KASSENID); statement.setInt(1, kassenid); ResultSet rs = statement.executeQuery(); diff --git a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java similarity index 85% rename from src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java rename to src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java index edceed9..e680c1c 100644 --- a/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java +++ b/src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java @@ -7,14 +7,14 @@ import java.sql.SQLException; /** * MySQL Connection Factory. */ -public class MySqlConnFactory { +public class MySqlConnectionFactory { public static final String URL = "jdbc:mysql://141.83.20.84:3306/pmiw15g06_v01"; public static final String USER = "pmiw15g06"; public static final String PASS = "AX3yQSYJSH43PrSz"; public static final String DRIVER = "com.mysql.jdbc.Driver"; - private static MySqlConnFactory instance = new MySqlConnFactory(); + private static MySqlConnectionFactory instance = new MySqlConnectionFactory(); - private MySqlConnFactory() { + private MySqlConnectionFactory() { try { Class.forName(DRIVER); } catch (ClassNotFoundException e) {