ソースを参照

Klasse ConnectionFactory umbenannt.

testBranch
コミット
182fa0c845
2個のファイルの変更26行の追加26行の削除
  1. +23
    -23
      src/main/java/de/uniluebeck/mi/projmi6/db/DBHandler.java
  2. +3
    -3
      src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnectionFactory.java

+ 23
- 23
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<Patient> getAllPatients() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_PATIENTS);

List<Patient> 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<Station> getAllStationen() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_STATIONEN);

List<Station> stationen = new ArrayList<>();
@@ -268,7 +268,7 @@ public class DBHandler {
}

public static List<StationsUebersichtsItem> 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<StationsHistorie> 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<Fall> 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<Icd10Code> getAllIcd10Codes() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_ICD10CODES);

List<Icd10Code> 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<OpsCode> getAllOpsCodes() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_OPSCODES);

List<OpsCode> 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<Mitarbeiter> getAllMitarbeiter() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_MITARBEITER);

List<Mitarbeiter> 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<Untersuchung> 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<Diagnose> 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<Kasse> getAllKassen() throws SQLException {
Statement statement = MySqlConnFactory.getConnection().createStatement();
Statement statement = MySqlConnectionFactory.getConnection().createStatement();
ResultSet rs = statement.executeQuery(SELECT_ALL_KASSEN);

List<Kasse> 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();



src/main/java/de/uniluebeck/mi/projmi6/db/MySqlConnFactory.java → 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) {

読み込み中…
キャンセル
保存