You should commit transaction in the try block because this way you can rollback any error caused by the transaction commit itself. If you do transaction commit in the finally block and transaction commit throws error then your code will blow up.