Sets up database connection