Commit bb980a0b authored by Oleh Astappiev's avatar Oleh Astappiev
Browse files

Read database credentials from properties file

parent bebffd5e
# Compiled files
# Database credentials
......@@ -4,18 +4,17 @@ import de.l3s.shs.shsclienttest.test.Runner;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
public class DatabaseLogger {
private static final Logger logger = LogManager.getLogger(Runner.class);
private static final String databaseHost = "";
private static final String databaseName = "shs_evaluation";
private static final String databasePassword = "Ask Philipp, if you need";
public enum ProbeType {
......@@ -38,9 +37,22 @@ public class DatabaseLogger {
private String comment;
private PreparedStatement insertStatement;
private DatabaseManager databaseManager = new DatabaseManager(databaseHost, databaseName, databaseName, databasePassword);
private DatabaseManager databaseManager;
public DatabaseLogger(ProbeType probeType, String comment) throws SQLException {
try (InputStream input = DatabaseLogger.class.getClassLoader().getResourceAsStream("")) {
Properties prop = new Properties();
if (input == null) {
throw new IOException("Sorry, unable to find");
databaseManager = new DatabaseManager(prop.getProperty(""), prop.getProperty("database.table"), prop.getProperty("database.username"), prop.getProperty("database.password"));
} catch (IOException ex) {
throw new RuntimeException("Can't read database credentials", ex);
insertStatement = databaseManager.prepareStatement("INSERT INTO request (probe_id, request_type, value, execution_time, results_count) VALUES (?, ?, ?, ?, ?);");
...... = "localhost:3306";
database.table = "username";
database.username = "username";
database.password = "password";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment