I need to handle sqlexcpetion and show the specific error message to the user, due to which perticular scenario this exception has been thrown.
Can anyone please help where would i get these information?
The SQLException class has methods which give you all that information. There are additional data in SQLException which are not available in ordinary Exceptions; you would have to check the documentation of the database you are using for their details.
This is not a "beginning Java™⅛ question, so I shall move it to our databases forum.