[(Exodus 30:12:) WHEN YOU LIFT UP <THE HEAD, i.e. take a census>.] This is what Scripture says (in Psalm 3:3 [2]): "MANY SAY OF MY SOUL …" This refers to David, when that deed came to his hand. They said: A man who carried off the ewe-lamb, and killed the shepherd, and felled Israel by the sword — does he have deliverance? (As that same verse continues:) "THERE IS NO SALVATION FOR HIM IN GOD." David said (in verse 3 [2]): And You, O Lord, agreed with them, and You wrote in the Torah (at Leviticus 20:10): "THE ADULTERER AND THE ADULTERESS SHALL SURELY BE PUT TO DEATH." Yet (according to Psalm 3:4 [3]) <You are> "A SHIELD ABOUT ME" — for You shielded me through the merit of my fathers, <You> who restored me to the kingship; and (the verse continues) "THE LIFTER OF MY HEAD." Instead of the lifting of the head that I owed You, You gave me an uplifted head, at the hands of Nathan the prophet, [who said to me] (in II Samuel 12:13): "THE LORD ALSO HAS PUT AWAY YOUR SIN; YOU SHALL NOT DIE."
David, Nathan, and the Lifted Head After Bathsheba
Midrash Tanchuma Buber, Ki Tisa 3:1
[כי תשא]. זש"ה רבים אומרים לנפשי וגו' (תהלים ג ג), זה דוד כשהגיע לידו אותו מעשה, אמרו מה אדם ששבה הכבשה והרג את הרועה והפיל את ישראל בחרב יש לו תשועה, אין ישועתה לו באלהים (שם), אמר דוד, ואתה ה' הסכמת עמהם, וכתבת בתורה מות יומת הנואף והנואפת (ויקרא כ י), אלא מגן בעדי (שם), שהגנת עלי בזכות אבותי, שהחזרתי אותי למלכות, ומרים ראשי (שם), תחת אשר הייתי חייב לך הרמת ראש, נתת לי תלוי ראש, על ידי נתן הנביא, [שאמר לי] גם ה' העביר חטאתך לא תמות (ש"ב יב יג).