package no.valg.valgnatt.database.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Database {

    private Database() {
        //Hide default constructor
    }

    public static Connection getConnection(String type) {
        try {
            Class.forName(ConfigurationLoader.getProperty("db." + type + ".driver"));
            return DriverManager.getConnection(ConfigurationLoader.getProperty("db." + type + ".url"),
                    ConfigurationLoader.getProperty("db." + type + ".user"),
                    ConfigurationLoader.getProperty("db." + type + ".password"));
        } catch (ClassNotFoundException | SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
