David's time was coming to an end. So he commanded Solomon his son,
References for 1 Kings 2:1
"I'm following the path that the whole earth takes. Be strong and be a man.
Guard what is owed to the LORD your God, walking in his ways and observing his laws, his commands, his judgments, and his testimonies, just as it is written in the Instruction from Moses. In this way you will succeed in whatever you do and wherever you go.
So also the LORD will confirm the word he spoke to me: ‘If your children will take care to walk before me faithfully, with all their heart and all their being, then one of your own children will never fail to be on the throne of Israel.'
You should know what Joab, Zeruiah's son, has done to me and what he did to the two generals of Israel, Abner, Ner's son, and Amasa, Jether's son. He murdered them, spilling blood at peacetime and putting the blood of war on the belt around his waist and on the sandals on his feet.
So act wisely: Don't allow him to die a peaceful death.
As for Barzillai's sons from Gilead, show them kindness. Let them eat with you. When I was running away from your brother Absalom, they came to me.
Now as for this Shimei, Gera's son—a Benjaminite from Bahurim—who is with you, he cursed me viciously when I went to Mahanaim. When he came down to meet me at the Jordan, I swore to him by the LORD, ‘Surely I won't execute you with the sword.'
But you don't need to excuse him. You are wise and know what to do to him. Give him a violent death."
Then David lay down with his ancestors and was buried in David's City.
He ruled over Israel forty years—seven years in Hebron and thirty-three years in Jerusalem.
Solomon sat on the throne of his father David, and his royal power was well established.
References for 1 Kings 2:12
Adonijah, Haggith's son, went to Bathsheba, Solomon's mother. She said, "Are you coming in peace?" He said, "Yes.
I have something to say to you." She said, "Say it."
He said, "You know how the kingdom was mine. All Israel had appointed me as their king. Then suddenly the kingdom went to my brother as the LORD willed.
Now I have just one request of you. Don't refuse me!" She said to him, "Go on."
Adonijah continued, "Ask King Solomon to let me marry Abishag from Shunem—he won't refuse you."
Bathsheba said, "Okay; I'll speak to the king for you."
So Bathsheba went to King Solomon to talk with him about Adonijah. The king stood up to meet her and bowed low to her. Then he returned to his throne and had a throne set up for the queen mother. She sat to his right.
She said, "I have just one small request for you. Don't refuse me." The king said to her, "Mother, ask me. I won't refuse you."
"Let Abishag from Shunem be married to your brother Adonijah," she said.
King Solomon replied to his mother, "Why ask only for Abishag from Shunem for Adonijah? Why not ask for the entire kingdom for him? After all, he is my older brother and has the support of Abiathar the priest and Joab, Zeruiah's son."
King Solomon swore by the LORD, "May God do to me as he sees fit! Adonijah has made this request at the cost of his life!
Now, as surely as the LORD lives—the one who supported me, put me on the throne of my father David, and provided a royal house for me exactly as he promised—Adonijah will be executed today."
So King Solomon sent Benaiah, Jehoiada's son. He attacked Adonijah, and Adonijah died.
The king said to the priest Abiathar, "Go to your fields at Anathoth, because you are a condemned man. However, I won't kill you today because you carried the LORD's chest in front of my father David and because you shared in all my father's sufferings."
So Solomon expelled Abiathar from the LORD's priesthood in order to fulfill the LORD's word that was spoken against Eli's family at Shiloh.
Now the news reached Joab because he had supported Adonijah, though he hadn't supported Absalom. Joab ran to the LORD's tent and grabbed the horns of the altar.
King Solomon was told that Joab had fled to the LORD's tent and was now beside the altar. So Solomon sent Benaiah, Jehoiada's son, instructing him, "Go. Attack Joab!"
Benaiah came to the LORD's tent and said to Joab, "The king says, ‘Come out!'" Joab said, "No! I'd rather die here." Benaiah sent a report back to the king: "This is what Joab said and how he answered me."
The king said to him, "Do as he said. Attack him and then bury him. In doing this, you will remove from me and from my father's royal house the guilt over the innocent blood that Joab shed.
May the LORD return that bloodguilt back on his own head for attacking the two men who were better and more righteous than he was. He murdered those two with the sword: Abner, Ner's son and Israel's general, and Amasa, Jether's son and Judah's general. But my father David didn't know about it.
May the bloodguilt for their deaths return on Joab's head and on the head of his family line forever. But may the LORD's peace be on David, his family, and his royal house forever."
So Benaiah, Jehoiada's son, went and attacked Joab and killed him. Joab was buried at his home in the wilderness.
In his place, the king gave leadership of the army to Benaiah, Jehoiada's son. The king put the priest Zadok in Abiathar's position.
Then he sent for Shimei and said, "Build a house for yourself in Jerusalem and stay in the city. Don't leave to go anywhere else.
If you try to leave, be advised that on the day you cross the Kidron Valley you will most certainly die. Your bloodguilt will be on your own head."
Shimei said to the king, "This is a good idea. Your servant will do just what my master the king said." So Shimei stayed in Jerusalem for a long time.
After three years, two of Shimei's servants fled to the king of Gath, Achish, Maacah's son. Shimei was informed, "Your servants are now in Gath."
Shimei saddled his donkey and went to Achish in Gath to look for his servants. Shimei then brought his servants back from Gath.
Solomon was told that Shimei had left Jerusalem for Gath and then returned.
The king sent for Shimei and asked him, "Didn't I make you swear a solemn pledge by the LORD? And didn't I swear to you, ‘If you try to leave and go anywhere, be advised that on that very day you will most certainly die'? You said to me, ‘This is a good idea. I agree to it.'
Why didn't you keep your solemn promise to the LORD and the command that I gave you?"
The king said further, "You know quite well all the evil that you did to my father David. May the LORD return your evil on your own head.
However, may King Solomon be blessed and David's throne be secure before the LORD forever."
Then the king commanded Benaiah, Jehoiada's son, who went and attacked Shimei, and he died. In these ways royal power was handed over to Solomon.