Waiting for database to open