How he sware unto the Lord - The solemn oath which he took that he would make this the first object; that he would give himself no rest until this was done; that he would sacrifice his personal ease and comfort in order that he might thus honor God. This oath or purpose is not recorded in the history. The fair interpretation of this would be either
(1) that these words properly expressed what was in the mind of David at the time - that is, his acts implied that this purpose was in his heart; or
(2) that this vow was actually made by David, though not elsewhere recorded. Such a vow might have been made, and the remembrance of it kept up by tradition, or it might have been suggested to the author of the psalm by direct inspiration.
And vowed unto the mighty God of Jacob - See Genesis 49:24. The God whom Jacob worshipped, and who had manifested himself so signally to him as a God of might or power.