Insert any way does not work here because when exception occurs while inserting records one by one the code goes out of loop afterwards in java. And select first I think making the application heavy as for every insert it needs to be fire a query. How to handle that.
Regards, Vijay Jamadade.
( Nothing is Impossible.)