“Finally” block will be executed irrespective of exception. So while executing the code in try block when an exception occurs, control is returned to catch block and at last “finally” block will be executed. So the closing connection to database / releasing the file handlers can be kept in “finally” block.