Reputation: 221
How to clear connection pool from dotnet(C#) once the process/connection is closed ? I am using sybase aseconnection , even after the connection is closed from ado.net , i could see some open connection in pool. Is there any way to clear those from dotnet code..Can anyone help me on this.
I am using sybase version ("Adaptive Server Enterprise/15.5/EBF 19397 SMP ESD#5/P/ia64/HP-UX B.11.23/asear155/2568/64-bit/FBO/Fri").
Upvotes: 2
Views: 5913
Reputation: 29811
According to the API documentation on the Sybase page, you can control the lifetime of a connection in the pool by setting the Connection Lifetime property in the connection string. It defaults to 0, which means indefinately.
From the AseConnection docs:
Connection Lifetime
The time, in seconds, that connections can stay open. When a client closes a connection that has reached or exceeded the defined Connection Lifetime, before the driver closes the connection instead of returning it to the connection pool. An idle connection is closed and removed from the connection pool once it reaches the defined Connection Lifetime.
The default value of Connection Lifetime is 0, which indicates that the connection can remain open for an indefinite amount of time.
A second interesting property is:
Connection Idle Timeout
The time, in seconds, that a connection can stay idle in the connection pool before the driver closes the connection. A value of 0 allows connections to stay idle for an indefinite amount of time.
You should be able to set them using this connection string (1 minute lifetime and idle timeout):
"Server=srv;Port=5000;uid=u;pwd=p;Connection Lifetime=60;Connection Idle Timeout=60;"
Upvotes: 10