In 2 Samuel 22, David praises God for being his Rescuer, his Refuge, his source of strength and success. You may notice that Psalm 18 is nearly the same, and meant as worship to our awesome God.
David’s “successes” are ultimately God’s doing. As David reflects on his rise to the throne, he understands that his rise to power and prominence is due to divine grace. He recalls the peril he was in and the death that seemed inevitable and unavoidable, and he praises God as his rescuer, his refuge, his source of strength and success. It is not as though David did nothing and waited for God to do everything; rather in spite of all David did, he knew it was God who preserved his life and God who promoted him to be the King of Israel. David exemplifies true humility here. Let us learn from him. If a man of his stature and spiritual intensity can give God the glory, certainly we should as well. As Paul once put it,
For who regards you as superior? What do you have that you did not receive? And if you did receive it, why do you boast as if you had not received it? (1 Corinthians 4:7)