I have a Spring mvc based web app where in DAO layer many try and catch blocks are there. We guys are planning to do some DB logging whenever any exception occurred. I found there is a Global Exception Handler(@ExceptionHandler) in Spring using which I can get rid of applying DB loggers in various catch blocks but unfortunately Global Exception Handler do not work as every time exception occurs its handled by existing catch block . is there any way to by pass existing catch blocks and use the global one ?
Usually not. Once you catch an exception, it's considered handled unless you re-throw it. However, you could try using AOP to inject an exception handler in your Spring components. You should be careful though, to not catch the same exception more than once, e.g. because it goes through multiple components until you finally catch it in your code.
You should also be aware that Spring takes checked exceptions from the underling technology and converts them into unchecked. Arguably this is "good" design as some would say that nobody ever really dealt with checked exceptions anyway. Of course some will disagree, but that's what spring does.
Also I believe that most vendor specific database (JDBC) exceptions are converted into springs own exceptions which are common across the vendors.