Implement case database connection per thread