The occasion of this psalm was the captivity of the Jews in Babylon, and the treatment they met with there; either as foreseen, or as now endured. Aben Ezra ascribes this psalm to David; and so the Syriac version, which calls it,
``a psalm of David; the words of the saints, who were carried captive into Babylon.''
The Septuagint, Vulgate Latin, and Ethiopic versions, make it to be David's, and yet add the name of Jeremiah; and the Arabic version calls it David's, concerning Jeremiah: but, as Theodoret observes, Jeremiah was not carried into Babylon, but, after some short stay in or near Jerusalem, was forced away into Egypt; and could neither be the writer nor subject of this psalm: and though it might be written by David under a spirit of prophecy; who thereby might foresee and foretell the Babylonish captivity, and what the Jews would suffer in it; as the prophets Isaiah and Jeremiah did, many years before it came to pass; yet it seems rather to have been written by one of the captivity, either while in it, or immediately after it.