Thanks for using the forum. I am happy to address your questions, and my answer will be based on the information you provided here. Please make sure you recognize that this forum is for educational purposes only, and it does not substitute for a formal office visit with a doctor.
Without the ability to examine and obtain a history, I can not tell you what the exact cause of the symptoms is. However I will try to provide you with some useful information.
Your post would be best served in an urology forum or general medicine forum. I would suggest you follow up with your primary care physician to ensure that you do not have an infection (such as epididymitis). You should also have an urinalysis performed to evaluate for an urinary tract infection and also have a xray of your abdomen to evaluate for kidney stones.
Thank you for this opportunity to answer your questions, I hope you find the information I have provided useful, good luck.