Prepare database connection