Resolving correct Database connection