When the British invaded neighboring Maryland in 1814, he served in the defense of Baltimore as a private in Henry Shippen's Company, 1st Brigade, 4th Division, Pennsylvania Militia, a unit of yagers. Buchanan is the only president with military experience who was not an officer. He is also the last president who served in the War of 1812.