|
|
|
@ -9,15 +9,6 @@ public class DBHandler {
|
|
|
|
|
|
|
|
|
|
DBHandler(DBConfig config) throws SQLException {
|
|
|
|
|
this.connection = config.getDbConnection();
|
|
|
|
|
//storeInDB(); // Löpt
|
|
|
|
|
//storeInDB("INSERT INTO Test (id, trash) VALUES (5, 4)"); //löpt to xD
|
|
|
|
|
}
|
|
|
|
|
public void storeInDB() {
|
|
|
|
|
try (Statement stmt = this.connection.createStatement()) {
|
|
|
|
|
stmt.executeUpdate("INSERT INTO Test (id, trash) VALUES (1, 2)");
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void storeInDB(String SQL) {
|
|
|
|
|
try (Statement stmt = this.connection.createStatement()) {
|
|
|
|
@ -28,10 +19,10 @@ 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("" +
|
|
|
|
|
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 + "' )");
|
|
|
|
|
|
|
|
|
|
"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();
|
|
|
|
|
}
|
|
|
|
|