Hi Arpan,
Not sure if this relate to your case, in our QA environment the java instance have problem from time to time.
When it have problem:
1) Query keep loading and no result return
2) No process found in SM51
3) No lock found in SM12
In this case we just restart the java instance and the query can run normally again.
Regards
Bill