At Wikipedia, it says: "The origins of the term are obscure. Around the same time the song came out, the expression "ballin' the jack" was used by railroad workers to mean "going at full speed," but it is not clear whether the dance or railroad reference came first."
And at Thoughtco.com it says: "No one knows for certain where or when the phrase originated, but "Balling the Jack" entered the North American lexicon as railroad slang that referred to a train going at full speed. "Balling" alluded to the balled fist a railroad engineer used to signal to his crew to pour on the coal so the train would travel faster. The "jack" was the train itself, a mechanical jackass that could carry heavy freight over great distances without tiring."