执行 SQLFreeHandle 后 ODBC 何时关闭连接?
这个问题与这个相关< /a>.
我遇到的问题是我们的应用程序有一个错误,它在 SQL 中留下了未关闭的事务。我确信连接已通过 SQLFreeHandle 释放,但看起来 ODBC 以某种方式保持连接打开以便稍后重用它。由于连接保持打开状态,事务不会回滚,并且我有锁。
有没有办法强制 ODBC 关闭连接并关闭底层套接字?
提前致谢。
this question is related with this one.
The problem I'm having is that our application has a bug and it leaves an unclosed transaction at SQL. I know for sure that the connection has been released with SQLFreeHandle but looks like somehow ODBC maintains the connection open to reuse it latter. As the connection remains open the transaction is not rolled back and I'm having a lock.
Is there a way to force ODBC to shutdown the connection and to close the underlying socket?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来连接池已打开。 本文介绍了如何在驱动程序级别将其关闭。
It sounds like connection pooling is turned on. This article describes how it can be turned off at the driver level.
正如 Mark 所说,连接池已打开。
通常,sql 驱动程序的包装器会在将连接释放回池之前进行回滚调用。
如果你们编写了自己的 ODBC 驱动程序(或其包装器),您可能会考虑修改连接处置/关闭/释放代码以在存在打开的事务时执行回滚。
As Mark said, connection pooling is turned on.
Typically the wrappers for the sql drivers make a rollback call prior to releasing the connection back to the pool.
If you guys have written your own ODBC driver (or wrapper for it), you might consider just modifying the connection dispose/close/release code to do that rollback if there was an open transaction.