Moving DB connection code to ConnectionFactory