Hello, I'm a small animal veterinarian and can help answer your question about Hammy.
Sorry to hear he is having this problem.
When we see blood coming from the urethra (or in the urine) - we worry about these possibilities: a urinary tract infection, bladder growths or stones, or kidney trouble.
2 years of age, unfortunately, is getting old for a hamster so it might not be so simple.
The only way to handle a urinary tract infection would be to make an appt with a local vet who will see hamsters for an injection of antibiotics, and/or an prescription to go home.
I would try this 1st, simply because the other alternatives in a 2 year old hamster are not as easily treatable.
Hopefully this helps - please feel free to respond with further questions or specifics.