add constructor to DBConfig
This commit is contained in:
parent
f5a54dfb74
commit
f8d5295347
@ -13,14 +13,14 @@ public class DBConfig {
|
|||||||
int port;
|
int port;
|
||||||
String server;
|
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.pw = pw;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
}
|
}
|
||||||
void setJsonConfig(JSONObject config){
|
DBConfig(JSONObject config){
|
||||||
this.pw = (String) config.get("pw");
|
this.pw = (String) config.get("pw");
|
||||||
this.db = (String) config.get("db");
|
this.db = (String) config.get("db");
|
||||||
this.user = (String) config.get("user");
|
this.user = (String) config.get("user");
|
||||||
|
@ -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) {
|
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()) {
|
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("" +
|
||||||
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 + "' )");
|
"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) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -11,8 +11,7 @@ public class Main {
|
|||||||
JSONObject config = store.readJSON("config.json");
|
JSONObject config = store.readJSON("config.json");
|
||||||
if (config == null) config = store.readJSON("example.config.json");
|
if (config == null) config = store.readJSON("example.config.json");
|
||||||
|
|
||||||
DBConfig dbConfig = new DBConfig();
|
DBConfig dbConfig = new DBConfig((JSONObject) config.get("dbConfig"));
|
||||||
dbConfig.setJsonConfig((JSONObject) config.get("dbConfig"));
|
|
||||||
|
|
||||||
DataStoreBot bot = new DataStoreBot(
|
DataStoreBot bot = new DataStoreBot(
|
||||||
config.get("storePath").toString(),
|
config.get("storePath").toString(),
|
||||||
|
Loading…
Reference in New Issue
Block a user