Page 1 of 1

Catching More Than One Exception in One Catch Block

Posted: Tue Feb 26, 2013 4:52 pm
by Sweetpin2
Hi,

Why below code is giving compilation error at catch statement

try{
// some of my codes

}catch(IOException|SQLException ex){

ex.printStackTrace();
}

I am getting below compilation error

IOException.SQLException cannot be resolved to a type
- Syntax error on token "|", . expected

As per the API we can have multiple exception handling in one catch.

Re: Catching More Than One Exception in One Catch Block

Posted: Tue Feb 26, 2013 5:17 pm
by admin
Are you sure you are using Jdk7 to compile?