"Deliver me from bloodguilt, O God" (Psalms 51:16) — deliver us from bloodguilt. Rabbi Yehoshua of Sikhnin in the name of Rabbi Levi said: For the blood of Saul he was not [slain] on my account. David pronounced three things upon the anointed of the Lord, and all three of them came upon him: "As the Lord lives, but the Lord shall smite him" (1 Samuel 26:10) — this happened to him; "or his day shall come and he shall die" — this happened to him; "or he shall go down into battle and perish" — this happened to him. For the blood of Nabal he was not slain on my account, [as it is said:] "And it came to pass about ten days [after, that the Lord smote Nabal, and he died]" (1 Samuel 25:38). For the blood of Samuel — that his planting was being cut down, and he did not grieve over it even one hour. For the blood of Nathan — that David would send messages behind his back to know whether he would scatter the words; had he scattered the words, he would not have killed him. For the blood of Israel — Rabbi Yehudah bar Rabbi Simon in the name of Rabbi Levi bar Perata: Why did the Scriptures not specify how many slain fell on Mount Gilboa? On account of "Tell it not in Gath" (2 Samuel 1:20). For the blood of Uriah — Rabbi Yehoshua ben Levi said: "Uriah the Hittite; thirty and seven in all" (2 Samuel 23:39). Rabbi Yonah of Botzrah said: that they brought him down from his greatness, for he was fit to be appointed after thirty-six, and they appointed him after thirty-seven. Rabbi Hanina bar Pappa in the name of Rabbi Hanina the scribe brings it from this: "Wherefore hast thou despised the word of the Lord... and thou hast slain him with the sword of the children of Ammon" (2 Samuel 12:9). And the Rabbis say: "thou hast slain him" — this teaches that he killed many righteous ones like him.
David Cleared of Bloodguilt for Saul Nabal and Uriah
Midrash Shmuel 25:2
הצילני מדמים אלהים וגו' (תהלים נ"א ט"ז), הצילנו מדמים, רבי יהושע דסכנין בשם רבי לוי אמר מדמו של שאול לא בשבילי [נהרג], שלשה דברים הוציא דוד על משיח ה' ושלשתן באו עליו, חי ה' כי אם ה' יגפנו (שמואל א' כ"ו י'), היא הות ליה, [או יומו יבא ומת, הוא הות ליה], או במלחמה ירד ונספה, היא הות ליה, מדמו של נבל לא בשבילי נהרג [שנאמר] ויהי (בעשרת) [כעשרת] הימים [ויגוף ה' את נבל וימת] (שמואל א' כ"ה ל"ח), מדמו של שמואל שהיה מטעת שלו נקצצת, ולא היה מצטער עליה אפילו שעה אחת, מדמו של נתן שהיה דוד משלח קורסיות לאחריו לידע אם מפזר הוא דברים, אילו היה מפזר דברים לא (הייתי) [היה] הורגו, מדמן של ישראל, רבי יהודה בר רבי סימון בשם רבי לוי בר פרטא מפני מה לא פירשו כתובים כמה חללים נפלו בהר הגלבוע, על שם אל תגידו בגת וגו' (שמואל ב' א' כ'), מדמו של אוריה, אמר רבי יהושע בן לוי אוריה החתי (וכל) [כל] שלשים ושבעה (שמואל ב' כ"ג ל"ט), רבי יונה בוצרייה אמר שהורידו אותו מגדולתו שהיה ראוי להתמנות אחר שלשים וששה, ומנו אותו לאחר שלשים ושבעה, רבי חנינא בר פפא בשם רבי חנינא ספרא מייתי לה מן הדה, מדוע בזית את דבר ה' וגו' ואותו הרגת בחרב בני עמון (שמואל ב' י"ב ט'), ורבנין אמרי אותו הרגת, מגיד שהרבה צדיקים כיוצא בו הרג.