Hi Karthik,
It’s difficult to determine the actual issue without code snippet, example data and full stack trace error.
I would suggest to simplify your code example, and trying out layer by layer.
For example, first test connecting to your MongoDB instance using your Java code.
If your issue is related more about JQuery or JqGrid you may get faster responses and reach wider audience by posting a question to StackOverflow.
Regards,
Wan.