private static Connection connect() throws SQLException, ClassNotFoundException {
		if (dbConnection != null && !dbConnection.isClosed()) {
			return dbConnection;
		}
        log.debug("Opening database connection...");
        try {
            Class.forName(dbProperties.getProperty("derby.driver"));
            dbConnection = DriverManager.getConnection(getDatabaseUrl(), dbProperties);
        } catch (SQLException ex) {
            log.error("Couldn't connect to the database.\n" +
                    "Message: {}\nError code: {}", ex.getMessage(), ex.getErrorCode());
            throw ex;
        } catch (ClassNotFoundException ex) {
            log.error("Couldn't load database driver.\n" +
                    "Message: {}", ex.getMessage());
            throw ex;
        }
        log.debug("Connection opened successfully.");
        return dbConnection;
    }