Add checking for database connection before save settings