"Fill your horn with oil and go, I will send you to Jesse" and so forth (I Samuel 16:1). "Happy is he whom You choose and bring near" and so forth (Psalms 65:5) — and Aaron was chosen. "And I have installed My king" and so forth (Psalms 2:6) — I established him firmly, as you say, "And she fastened it with the pin of the loom and the web" (Judges 16:14). "I anointed him," as you say, "and I did not anoint myself at all" (Daniel 10). "I drew him out from the sufferings." Rabbi Huna in the name of Rabbi Acha: The sufferings were divided into three portions — one for the generations and for the fathers, one for the generation of persecution, and one for the King Messiah. This is what is written, "And he was wounded because of our transgressions" and so forth (Isaiah 53). They say to the King Messiah, "Where do you seek David?" He said, "This too requires asking: 'Upon Zion, My holy mountain' (Psalms 2:6). Just as they are liable concerning its partition when it is built, so are they liable concerning its partition when it is destroyed." "And You have exalted my horn like that of a wild ox; I am anointed with fresh oil" (Psalms 92:11). Rabbi Yehuda ben Giron and Rabbi Yehoshua of Sikhnin in the name of Rabbi Levi — one said: Saul was anointed, but his shield was not anointed; and one said: neither he nor his shield. David said: "I am the vessel that holds the oil of greatness — 'And You have exalted my horn like that of a wild ox; I am anointed with fresh oil.'"
How God Chose, Established, and Anointed David in Midrash Shmuel
Midrash Shmuel 19:1
מלא קרנך שמן ולך אשלחך אל ישי וגו' (שמואל א' ט"ז א'), אשרי תבחר ותקרב וגו' (תהלים ס"ה ה'), ואהרן נבחר, ואני נסכתי מלכי וגו' (שם ב' ו'), השתיתיו, כמה דאת אמר ויסע את היתד הארג (עם) [ואת] המסכת (שופטים ט"ז י"ד), משחתו, כמה דאת אמר וסוך לא סכתי (דניאל י'), משכתיו מן הייסורין, ר' הונא בשם רבי אחא לשלשה חלקים נתחלקו הייסורין, אחד לדורות, ולאבות, ואחד לדורו של שמד, ואחד למלך המשיח, הדא הוא דכתיב והוא מחולל מפשעינו וגו' (ישעי' נ"ג), אומרים למלך המשיח איכן את מבקש לדוד, אמר אף דא צריכה שאילה על הר ציון הר קדשי (תהלים ב' ו'), כשם שחייבין על מחיצתו [והוא בנוי כך חייבים על מחיצתו] והוא חרב. ותרם כראם קרני בלותי בשמן רענן (תהלים צ"ב י"א), רבי יהודה בן גירון ורבי יהושע דסכנין בשם רבי לוי חד אמר שאול נמשח ומגינו לא נמשחה, וחד אמר לא הוא ולא מגינו, אמר דוד אנא כליית משחא דרבותא, ותרם כראם קרני בלותי בשמן רענן.