Error: Exception is never thrown in body of corresponding try statement

3,742 views
Skip to first unread message

vrk...@aim.com

unread,
Feb 12, 2009, 12:14:56 PM2/12/09
to javaprogrammi...@googlegroups.com
I am getting this error while compiling my code,

"Exception is never thrown in body of corresponding try statement"

any idea how i can fix this.

thanks




A Good Credit Score is 700 or Above. See yours in just 2 easy steps!

miga

unread,
Feb 12, 2009, 12:20:11 PM2/12/09
to Free Java Programming Online Training Course By Sang Shin
If you give us a little more context, it will help us to help you.

Katia Lage

unread,
Feb 12, 2009, 12:30:18 PM2/12/09
to miga...@gmail.com, Free Java Programming Online Training Course By Sang Shin
Probably you put a code into a try/catch block, but there isn't any occasion (any statement into the try block) that the exception you really occur.

Adam M. Dutko

unread,
Feb 12, 2009, 12:58:11 PM2/12/09
to vrk...@aim.com, javaprogrammi...@googlegroups.com
That means you are attempting to catch something that is never going
to be thrown and the compiler flagged it as a "removable" exception.
So remove the offending exception and try again. If it's the only
exception for the try block, remove the try block and the catch.

-Adam

Harriat Teresa Damian

unread,
Feb 12, 2009, 1:54:24 PM2/12/09
to vrk...@aim.com, javaprogrammi...@googlegroups.com
hi,
 
The problem is that the code that you have written in the try block will never  throw the checked exception that you are trying to handle in  the catch statement.There is no point in handling IOException when you are writing code for data base connectivity.
 
Warm Regards,
Teresa.
Reply all
Reply to author
Forward
0 new messages