Properly detect database connection issues