谢谢avdance,
乔治
解决方法
ADO.NET将为其创建一个新的连接池
>每个连接字符串;它对此非常挑剔 – 如果你有两个连接字符串,即使只是一个空格或其他东西也是不同的,那些被认为是两个独立的连接字符串,并将导致创建单独的连接池
>如果使用“集成安全性”(可信连接)设置,则为每个Windows凭据
所以如果你有一个类似的连接字符串
server=MyDBServer;database=MyDatabase;integrated security=sspI;
将创建一个用于每个可区分用户的连接池 – 这是相当反直觉的,但这就是它的方式(并且它不能被影响/关闭).
有关详细信息,请查看ADO.NET连接池上的MSDN docs:
When a connection is first opened,a
connection pool is created based on an
exact matching algorithm that
associates the pool with the
connection string in the connection.
Each connection pool is associated
with a distinct connection string.
When a new connection is opened,if
the connection string is not an exact
match to an existing pool,a new pool
is created. Connections are pooled per
process,per application domain,per
connection string and when integrated
security is used,per Windows
identity. Connection strings must also
be an exact match; keywords supplied
in a different order for the same
connection will be pooled separately.
此外,如果您有这两个连接字符串:
server=MyDBServer;database=MyDatabase;user id=tom;pwd=top$secret
和
server=MyDBServer;database=MyDatabase;user id=tom; pwd=top$secret;
那些被认为是不同的连接字符串,因此将创建两个单独的连接池.
在尝试测量连接池的效果时,需要注意这一点!
渣