|
|
@ -2,6 +2,9 @@ package sh.adb.sensorCommunityAPI;
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
|
|
public class dbHandler {
|
|
|
|
public class dbHandler {
|
|
|
|
String pw;
|
|
|
|
String pw;
|
|
|
@ -9,12 +12,16 @@ public class dbHandler {
|
|
|
|
String user;
|
|
|
|
String user;
|
|
|
|
int port;
|
|
|
|
int port;
|
|
|
|
String server;
|
|
|
|
String server;
|
|
|
|
|
|
|
|
Connection connection;
|
|
|
|
|
|
|
|
|
|
|
|
dbHandler(JSONObject config){
|
|
|
|
dbHandler(JSONObject config) throws SQLException {
|
|
|
|
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");
|
|
|
|
this.port = (Integer) config.get("port");
|
|
|
|
this.port = (Integer) config.get("port");
|
|
|
|
this.server = (String) config.get("server");
|
|
|
|
this.server = (String) config.get("server");
|
|
|
|
|
|
|
|
Connection connection = DriverManager.getConnection(
|
|
|
|
|
|
|
|
"jdbc:mariadb://"+this.server+":"+this.port+"/"+this.db+"?user="+this.user+"&password="+this.pw
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|