Lots of questions for you
.
When did you take him to the vet last? What tests were done? Was a urine sample taken?
If he was perfectly house trained, I'm thinking this is more a medical issue than behavioral, especially given his age. Do you have any history on him? Why was he given up? Do you know when he was neutered? Are there any female dogs that could be in heat nearby (or having had visited). Male dogs?