The title of your request refers to James, while the text refers to John.The records I found seem to indicate James as your target.
James A. Roberts, Baldwin County, enlisted 3-4-62 in the GA 45th Infantry, Co.G.He was transferred on 12-24-64 to the Veteran Reserve Corps.Possibly he was still debilitated from his wounding at Mechanicsville, VA on 6-26-1862.
Another Roberts in the GA 45th was Nicolas C.He enlisted the same date, but was discharged for minority (date not known).He was on the roster 9-27-62 in Richmond, VA receiving pay.
Also in Company G was Sterling.Mentioned as being from Baldwin County, he was made a POW at Fort Stedman, VAon 3-28-65, then was transferred to Point Lookout, MD approximately 3-28-65.He took the oath of allegiance on 6-17-65 and was released.
I'd be very surprised if this was the Sterling born in 1790.Not much chance of a person 72 years of age being allowed in the field.(heck, I'm 2 years past that, and you would have to have a fire lit under me to get mean enuf to want to shoot a yankee((an obama dimmycrat would be another matter))