When King David was settled in his palace and the lord had given him rest from all the surrounding enemies,