Ignacio Soler Garcia
Ignacio Soler Garcia

Reputation: 21855

When does ODBC closes a connection after doing a SQLFreeHandle?

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.

Upvotes: 1

Views: 1190

Answers (2)

ChrisLively
ChrisLively

Reputation: 88062

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.

Upvotes: 1

Mark Wilkins
Mark Wilkins

Reputation: 41242

It sounds like connection pooling is turned on. This article describes how it can be turned off at the driver level.

Upvotes: 2

Related Questions