Once, then a second time three weeks later is not a serious problem, but you may be able to find an answer. Your veterinarian should rule out some of the basic things first. I would want to know the dog does not have a bladder infection. Urine tests will determine that. Can usually be treated with a simple course of antibiotics. Next an x-ray would make sure your dog does not have bladder stones.
Finally, basic system blood tests may reveal something like kidney disease or diabetes.
Take these first steps and let us know how he does.
We'll be going to the vet tomorrow and I'll let you know the outcome. Thank you.