check if db is available first