Vishal Yadav, a diploma engineer, was found hanging in his room, a police spokesperson said.
Messages found in his phone and diary indicated that a failed relationship led him to take the step, he said.
Vishal was upset after the girl refused to speak to him, police said.
Police have sent the body for postmortem and further investigation into the case is on.