Quintin Par
Quintin Par

Reputation: 16252

Connection Lifetime=0 in MySql connection string

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

Upvotes: 5

Views: 7799

Answers (4)

Redwood
Redwood

Reputation: 69302

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.

Upvotes: 4

Mitch Wheat
Mitch Wheat

Reputation: 300549

Updated: A value of zero (0) causes pooled connections to have the maximum connection timeout.

Ref.

Upvotes: 1

Myra
Myra

Reputation: 3656

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

Upvotes: 2

IordanTanev
IordanTanev

Reputation: 6240

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.

Upvotes: -1

Related Questions