diff --git a/src/main/java/sh/adb/sensorCommunityAPI/DBConfig.java b/src/main/java/sh/adb/sensorCommunityAPI/DBConfig.java index c3d2f62..57bc8df 100644 --- a/src/main/java/sh/adb/sensorCommunityAPI/DBConfig.java +++ b/src/main/java/sh/adb/sensorCommunityAPI/DBConfig.java @@ -13,14 +13,14 @@ public class DBConfig { int port; String server; - void setConfig(String pw, String db, String user, int port, String server){ + DBConfig(String pw, String db, String user, int port, String server){ this.pw = pw; this.db = db; this.user = user; this.port = port; this.server = server; } - void setJsonConfig(JSONObject config){ + DBConfig(JSONObject config){ this.pw = (String) config.get("pw"); this.db = (String) config.get("db"); this.user = (String) config.get("user"); diff --git a/src/main/java/sh/adb/sensorCommunityAPI/DBHandler.java b/src/main/java/sh/adb/sensorCommunityAPI/DBHandler.java index 2c9d3a0..afd8d75 100644 --- a/src/main/java/sh/adb/sensorCommunityAPI/DBHandler.java +++ b/src/main/java/sh/adb/sensorCommunityAPI/DBHandler.java @@ -28,8 +28,9 @@ public class DBHandler { } public void storeInDB(String country, int sensorID, String timeStamp, String value_type_p1, int id_p1, float value_p1, String value_type_p2, int id_p2, float value_p2, String allJSON) { try (Statement stmt = this.connection.createStatement()) { - //stmt.executeUpdate("INSERT INTO apidata (id, country, sensorID, Timestamp, value_type_p1, id_p1, value_p1, value_type_p2, id_p2, value_p2, allJSON ) VALUES (0, " + country + ", " + sensorID + ", " + timeStamp + ", " + value_type_p1 + ", " + id_p1 + ", " + value_p1 + ", " + value_type_p2 + ", " + id_p2 + ", " + value_p2 + ", " + allJSON + ")"); - stmt.executeUpdate("INSERT INTO apidata (id, country, sensorID, Timestamp, value_type_p1, id_p1, value_p1, value_type_p2, id_p2, value_p2, allJSON ) VALUES ( NULL , '" + country + "', " + sensorID + " , '" + timeStamp +"', '" + value_type_p1 + "', " + id_p1 + ", " + value_p1 + ", '" + value_type_p2 + "', " + id_p2 + " , " + value_p2 + " , '" + allJSON + "' )"); + stmt.executeUpdate("" + + "INSERT INTO apidata (id, country, sensorID, Timestamp, value_type_p1, id_p1, value_p1, value_type_p2, id_p2, value_p2, allJSON )" + + "VALUES ( NULL , '" + country + "', " + sensorID + " , '" + timeStamp +"', '" + value_type_p1 + "', " + id_p1 + ", " + value_p1 + ", '" + value_type_p2 + "', " + id_p2 + " , " + value_p2 + " , '" + allJSON + "' )"); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/main/java/sh/adb/sensorCommunityAPI/Main.java b/src/main/java/sh/adb/sensorCommunityAPI/Main.java index a218b71..48f0d57 100644 --- a/src/main/java/sh/adb/sensorCommunityAPI/Main.java +++ b/src/main/java/sh/adb/sensorCommunityAPI/Main.java @@ -11,8 +11,7 @@ public class Main { JSONObject config = store.readJSON("config.json"); if (config == null) config = store.readJSON("example.config.json"); - DBConfig dbConfig = new DBConfig(); - dbConfig.setJsonConfig((JSONObject) config.get("dbConfig")); + DBConfig dbConfig = new DBConfig((JSONObject) config.get("dbConfig")); DataStoreBot bot = new DataStoreBot( config.get("storePath").toString(),