Extract db url connection logic to class