[3.8] Fix database connection detection