David was a type of Christ in many ways including:
David was a prophet as well as a king; so was our Lord.
David was anointed about the 30th year of his life; so Christ, the son of David, was baptized and anointed at 30.
David in his wars had many poor men follow him such as were in debt; so Jesus Christ had many poor men who followed Him, and became His disciples, who were heavy laden under the burden of sin, called a debt.
Adapted from Preaching From Types and Metaphors by Benjamin Keach, Kregel Publications, Grand Rapids, MI, 1972 A.D. edition. Benjamin Keach was a Baptist Preacher in London who lived from 1640- 1704.This work was originally called Tropologia.