C# MySQL 连接字符串中的“pooling=false”是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18336961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 11:58:01  来源:igfitidea点击:

What does "pooling=false" in a MySQL connection string mean?

c#mysql.netconnection-string

提问by Bruno Casali

What does pooling=falsein a .NET connection-string for a MySQL database mean?

是什么pooling=false在.NET连接字符串MySQL数据库是什么意思?

This is the complete connection string:

这是完整的连接字符串:

return new MySqlConnection("SERVER=localhost;DATABASE=myDataBase;USER=###;PASSWORD=***;POOLING=FALSE;");

采纳答案by Rahul Tripathi

When pooling=falsethe connection will not return to the pool when you call SqlConnection.Close()

pooling=false连接不会返回池时调用SqlConnection.Close()

From MSDN

来自MSDN

When the value of this key is set to true, any newly created connection will be added to the pool when closed by the application. In a next attempt to open the same connection, that connection will be drawn from the pool. Connections are considered the same if they have the same connection string. Different connections have different connection string

当此键的值设置为 true 时,任何新创建的连接都会在应用程序关闭时添加到池中。下次尝试打开同一个连接时,将从池中提取该连接。如果连接具有相同的连接字符串,则它们被认为是相同的。不同的连接有不同的连接字符串

回答by sircodesalot

Will the connection be part of a connection pool or not? This means that the connection be shared throughout the application instead of creating a new one every time you call open.

连接是否是连接池的一部分?这意味着连接在整个应用程序中共享,而不是每次调用 open 时都创建一个新连接。

Note that for connection pooling to work, the connection string must be EXACTLY the same, meaning you cannot change a character in the string (even whitespace) and have pooling still work. Thus, the connection created by:

请注意,要使连接池工作,连接字符串必须完全相同,这意味着您不能更改字符串中的字符(甚至是空格)并且池仍然有效。因此,通过以下方式创建的连接:

"SERVER=localhost;DATABASE=myDataBase;USER=###;PASSWORD=***;POOLING=FALSE;"

will not be shared with a connection created by:

不会与以下创建的连接共享:

" SERVER=localhost;DATABASE=myDataBase;USER=###;PASSWORD=***;POOLING=FALSE;"

because of the leading space.

因为领先的空间。