It's funny how this is now classified as a children's folk song. It was a popular hit of the 1840's minstrel stage which I understand to have a scottish origin. It's easy to find the early versions in music libraries, both in sheet and songster format. There are a couple of versions in Ira Ford's TRADITIONAL MUSIC OF AMERICA.