Do I need to call rollback if I never commit?

前端 未结 1 1661
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 09:54

I am connecting to a SQL Server using no autocommit. If everything is successful, I call commit. Otherwise, I just exit. Do I need to explicitly call rollback, or will it be

相关标签:
1条回答
  • 2020-12-17 10:40

    It should roll back on close of connection. Emphasis on should for a reason :-)

    Proper transaction and error handling should have you always commit when the conditions for commit are met and rollback when they aren't. I think it is a great habit to always commit or rollback when done and not rely on disconnect/etc. All it takes is one mistake or incorrectly/not closed session to create a blocking chain nightmare for all :-)

    0 讨论(0)
提交回复
热议问题