God's covenant with David, which is found in 2 Samuel 7:12-17, claims that God will establish David's kingdom after David's death. The person who rules that kingdom will build God a house, and God will make the kingdom's throne eternal. He then goes on to say that this ruler will be like a son to God and that God will discipline him when he sins but never depart from him. God then repeats the promise that David's kingdom will be forever established.
In this covenant, God prophetically speaks both to the immediate future and the distant future. David's direct heir, Solomon, is known to have built the temple in Jerusalem and committed sins against God by marrying women who led him astray. Therefore, he is the figure specifically referenced in verses 13-15.
However, there is also reference to an everlasting kingdom being established. After Solomon's reign, the kingdom of Israel split and has since faced many obstacles. It cannot, therefore, merely be Solomon's reign that God speaks of in this covenant. God speaks also of the coming of the Messiah, Jesus Christ, who would be in the line of David. Isaiah, the Old Testament prophet, reiterates this in Isaiah 9:7: "Of the increase of his government and of peace there will be no end, upon the throne of David and over his kingdom to establish it and to uphold it with justice and with righteousness from this time forth and forevermore." Jesus, born of Mary, was indeed born into the line of David. However, as God, He also remains forever. Revelation 17:14a establishes Jesus as this eternal king when it reads, "They will make war on the Lamb, and the Lamb will conquer them, for he (Jesus, the Lamb) is Lord of lords and King of kings."