I want to throw any exception that occurs while doing MySQL transaction to the application. But before that I want to close any resources that are in open state. But closing these resources might again generate exception which again I would want to report to application. The following code will make this a little clear:
try
{
// connect to MySQL DB using JDBC and run different queries
}
catch ( Exception e )
{
// throw this exception by wrapping it in another user defined exception class
}
finally
{
try
{
// close resources opened in try block ( statement, connection )
}
catch ( Exception e )
{
// throw this exception by wrapping it in another user defined exception class
}
}
I want to know what is the correct way to handle this situation ( having two exception being thrown ). Thanks for your help.