Robert the Bruce died when David II was only five. So he wound up a boy king, and was deposed and restored as he vied with Edward Balliol. He also spent about 20 years facing captivity, but seems to have stabilized his rule during the last decade of his life.
Married off at four-years-old to a seven-year-old Joanna, David remained married to her for 34 years. But said to be a loveless match, they never had kids.
A few years after his release by the English, he went on to marry Margaret Drummond in February of 1364 ... but the couple divorced without issue on 20 March 1370. He died the next year, and the throne passed to the Stewarts through his nephew Robert.
A History of Northumberland (Lodon, 1893) Vol. 1, Page 39-40: "After the battle of Neville's Cross in 1346, David Bruce, 'who called himself king of Scotland,' was brought a prisoner to Bamburgh. Masters William de Bolton and Hugh de Kilvington, barber surgeons, came to the castle from York to extract the arrow with which he had been wounded in the battle, and to heal him with despatch. They received L6 for their services." citing Rymer Faedera, III. i. p. 109.
G.E. Cokayne; with Vicary Gibbs, H.A. Doubleday, Geoffrey H. White, Duncan Warrand and Lord Howard de Walden, editors, The Complete Peerage of England, Scotland, Ireland, Great Britain and the United Kingdom, Extant, Extinct or Dormant, new ed., 13 volumes in 14 (1910-1959; reprint in 6 volumes, Gloucester, U.K.: Alan Sutton Publishing, 2000)
Alison Weir, Britain's Royal Families: The Complete Genealogy (London, U.K.: The Bodley Head, 1999)
Sir James Balfour Paul, The Scots Peerage: founded on Wood's edition of Sir Robert Douglas's The Peerage of Scotland (Edinburgh, Scotland: David Douglas, 1904)
Leslie Stephen, editor, Dictionary of National Biography (London, U.K.: Smith, Elder & Company, 1908)