Hi Gayathri,
The Exceptin you mentioned is nohing to do with the CODE. It is problem with the data you are trying to access with the code.
Please check there should be some duplicate entry at data level,remove one entry andthen give a try. I trust you see results with out exception .