First let me say you did the right thing by keeping your cat indoors. It is not safe outside as you learned.
First you need to bring your cat to the vet to see if it has a urinary tract infection. I am assuming he is neutered.
If it doesn't have an infection, you need to be sure you have some cat toys and places to climb hide etc which will make your cat feel like it still has the freedom of the outside. Your vet can also advise on other behavior tactics.
Hope this helps.
Let me know how he does.
Keep Your Pets Healthy and Living Longer!