Yahweh said to Samuel, How long will you mourn for Saul, seeing I have rejected him from being king over Israel? fill your horn with oil, and go: I will send you to Jesse the Bethlehemite; for I have provided me a king among his sons.
"I will send you to Jesse the Bethlehemite"  (1 Samuel 16:1).  Jesse's genealogy is given in  Ruth 4:18-22 all the way back to Judah and his daughter-in-law Tamar.  Thus, David was the great-grandson of Boaz and Ruth.