When David was near death he told his son Solomon important details to help him be a good king. In the beginning of his reign Solomon had to man up and kill people that could jeopardize and compromise his rule over Israel.
2 Kings 2:1-12
2 As the time of King David’s death approached, he gave this charge to his son Solomon:
2 “I am going where everyone on earth must someday go. Take courage and be a man. 3 Observe the requirements of the Lord your God, and follow all his ways. Keep the decrees, commands, regulations, and laws written in the Law of Moses so that you will be successful in all you do and wherever you go. 4 If you do this, then the Lord will keep the promise he made to me. He told me, ‘If your descendants live as they should and follow me faithfully with all their heart and soul, one of them will always sit on the throne of Israel.’
5 “And there is something else. You know what Joab son of Zeruiah did to me when he murdered my two army commanders, Abner son of Ner and Amasa son of Jether. He pretended that it was an act of war, but it was done in a time of peace, staining his belt and sandals with innocent blood. 6 Do with him what you think best, but don’t let him grow old and go to his grave in peace.
7 “Be kind to the sons of Barzillai of Gilead. Make them permanent guests at your table, for they took care of me when I fled from your brother Absalom.
8 “And remember Shimei son of Gera, the man from Bahurim in Benjamin. He cursed me with a terrible curse as I was fleeing to Mahanaim. When he came down to meet me at the Jordan River, I swore by the Lord that I would not kill him. 9 But that oath does not make him innocent. You are a wise man, and you will know how to arrange a bloody death for him.”
10 Then David died and was buried with his ancestors in the City of David. 11 David had reigned over Israel for forty years, seven of them in Hebron and thirty-three in Jerusalem. 12 Solomon became king and sat on the throne of David his father, and his kingdom was firmly established.