It's my understanding that this song goes back at least to the War of 1812 and that the melody is older. Whether that's true or not, I don't know. I have seen several different versions of lyrics. I think it's just one of those that's so old, and has undergone so many transformations, the original composer is lost to history.