posted 17 years ago
Hi Shiv Mohan,
You place the method call of code statements that may throw certain exception in the try block and then place catch block followed by that to handle that exception. If inside the try block the checked exception is not thrown, and you put catch block to handle that exception, compiler complaints that "are you sure you are doing write; there is nothing like SQLException in the try block, so for what you are handling that". Hence compilation error.
If you throw any checked exception in the catch block too, that exception must either be in the try catch block or declared to be thrown by the method. catch block placed to handle try block code never goes to handle exceptions generated in the catch block itself. That is what, as I see the matter of confusion to you. Is that right?
Thanks and Regards,
cmbhatt