It throws " exception java.sql.exception has already been caught.
No, it doesn't throw anything. It's a compile error.
If sqlexception caught in catch(Exception e) block then why catch(sqlexception)
SQLException extends Exception, so if you catch Exception first, you'll never be able to reach the SQLException catch block. However, if you place the SQLException catch block before the Exception one, you'll be able to catch SQLException specifically, and catch all other Exceptions in the other catch block. You always have to write multiple catch blocks from most specific, to most general.
Joined: Jul 09, 2010
yes, not only for SQLException, but for any exception, this holds true. The catch(Exception e) must be last in the series of catch blocks that you might have.