Thanks for query,
It seems that you might have some problem in the kidney or urethra.
Consult your doctor and discuss about ultra sound
of kidney to rule out stones and cystoscopy
of bladder and urethra.
As there is chance of having urethritis
you may stop masturbation
for the time being as it may produce soreness in the urethra.
Take plenty of water.
Ok and bye.