Then the three mighty men broke through the camp of the Philistines and drew water out of the well of Bethlehem that was by the gate and carried and brought it to David. But he would not drink of it. He poured it out to the LORD and said, “Far be it from me, O LORD, that I should do this. Shall I drink the blood of the men who went at the risk of their lives?” Therefore he would not drink it. These things the three mighty men did.
2 Samuel 23:16-17 ESV
This may at first seem wasteful of David, and ungrateful, but it is a gesture showing great value. He likens the water to the blood of his men, and for David to drink the water obtained at the risk of their lives would have been to take their blood lightly. But to pour it out before the Lord was a way of saying that he was not worthy of it, and he was offering it to the Lord instead. Such “drink offerings” were often poured out before the Lord: see Gen. 35:14; Num. 15:7–10; 28:7–15