Robert Davidson, 54, was stopped by police late on Thursday night driving a car in his home town of Selkirk in the Borders.
He appeared from custody at Jedburgh Sheriff Court where he admitted driving while banned and with no insurance. Procurator fiscal Graham Fraser said it was his eighth conviction for driving while disqualified and with no insurance.
Defence lawyer Rory Bannerman said his client had a heart problem and had only six months to live.
But jailing him for four months and banning him from the road for four years, Sheriff Kevin Drummond said: "Your health matters can be dealt with in the prison system."