These last verses have brought the psalm to a satisfying climax. David is in danger of being killed by King Saul; but he has found a refuge in God. He has been driven away from home, possessing nothing; but God is his portion. He is in danger of being overcome by people who are stronger than he is; but God is his Savior. He feels that he is shut up in the prison of his cave; but God is his liberator who will set him free. David knows that he is to be king of Israel. Therefore, finally, he anticipates a day when “... the righteous will gather about me because of your goodness to me” (v. 7).

What did David see when he was in the cave alone? He saw that God was four important things to him and for him. We have already covered the first thing in yesterday's study, that of a refuge. Let's look at the next three points. 

In verses 3 and 4, David's "complaint” (v. 2) comes to full expression. It has two parts. First, the path before me is a dangerous one, full of the snares of my enemies; I need help. Second, I have no friends here, I am alone; if you don't support me, I am lost. As it turned out, God did protect David from Saul's snares, and it was while he was at the cave of Adullam that his brothers and others came to join him to the number of about four hundred faithful fighting men. 

The first two verses set the tone for the psalm, because here David is pouring out his distress before God, seeking God's help in his trouble. He is praying urgently. 

In Psalm 142 David is alone and in trouble. We know this not only because the psalm speaks of his being alone and in trouble, but because it begins with a title line saying that it was written "when [or about the time when] he was in the cave.” This is the only psalm in this final collection of Davidic psalms (Psalms 138-145) that provides the reader with a setting: “A maskil of David. When he was in the cave. A Prayer.” But it is helpful for our understanding of the psalm since we know something about David's situation at this time from the account of these days in 1 Samuel 22:1, 2. Even more, it makes Psalm 142 a companion to Psalm 57, which likewise begins: “Of David. A miktam. When he had fled from Saul into the cave.”