views:

1073

answers:

4

What exactly does Connection Lifetime=0 mean in a connection string?

+3  A: 

It means no connection timeout.

Mitch Wheat
This is incorrect. See my answer: http://stackoverflow.com/questions/1233488/connection-lifetime0-in-mysql-connection-string/3444881#3444881
Lawrence Johnston
+1  A: 

It means there is no connection time out period. For example if it is set 300 if in this time query is not completed, let's say because there is lot of data, a time out exception will be thrown. When it is say 0 it will work until query is completed.

IordanTanev
This is incorrect. See my answer: http://stackoverflow.com/questions/1233488/connection-lifetime0-in-mysql-connection-string/3444881#3444881
Lawrence Johnston
+2  A: 

In addition, When you use Connection LifeTime: It destroys pooled connections If the time your connection is opened for is larger than Connection LifeTime,connection is not usable.

I suggest that using Connection LifeTime if you have not a connection within a cluster of server

Myra
A: 

Based on my research I believe that Myra is the closest of the other answers.

It is not the same as the connection timeout.

Instead see this pseudocode from this article:

On SqlConnection.Close

   Check if time the connection has been open is greater than Connection Lifetime if it is, throw the connection away

   Else Put connection on the pool

The same article explains why you would rarely want to use this property (and the situations in which you might).

Note that it has been renamed to "Load Balance Timeout" in an attempt to clarify its behavior per the above article.

Lawrence Johnston