The only U.S. President that was a bachelor while he was President, was James Buchanan Jr. He was the 15th President of the United States from 1857 to 1861.
Buchanan was a lawyer, a diplomat, and before becoming President, was a politician, serving as Secretary of State and represented Pennsylvania in both houses of the U.S. Congress.