God made a promise to David through Nathan the prophet that has been widely misunderstood.
I declare to you that the LORD will build a house foryou: When your days are over and you go to be with your fathers, I will raise up your offspring to succeed you, one of your own sons, and I will establish his kingdom. He is the one who will build a house for me, and I will establish his throne forever. I will be his father, and he will be my son. I will never take my love away from him, as I took it away from your predecessor. I will set him over my house and my kingdom forever; his throne will be established forever (1 Chron 17:10-14).
Nathan's promise to David was fulfilled in Jesus. God said of Jesus, I will be his father, and he will be my son. Jesus established the kingdom of God, which will last forever. This understanding is confirmed in God’s answer to Solomon's prayer. God did not promise that his family line would continue as kings of Israel.
And if you walk in my ways and obey my statutes and commands as David your father did, I will give you a long life (1 Kings 3:14).God only promised long life to Solomon. He did not establish a kingly dynasty through him.
Jesus is the ideal King.