必须建立物理通道(例如套接字或命名管道),必须与服务器进行初次握手,必须分析连接字符串信息,必须由服务器对连接进行身份验证,必须运行检查以便在当前事务中登记,等等。
的优化技术。
调用中重复使用。
的不同实例将使用不同的连接池,即使用户 ID 和密码相,也是如此。
有关更多信息,请参见本主题后面的“使用连接字符串关键字控制连接池”。
|
|
|---|
|
阻塞期结束后的后续失败将导致新的阻塞期,该阻塞期的持续时间是上一个阻塞期的两倍,最长为一分钟。 |
连接字符串还必须是完全匹配的;按不同顺序为同一连接提供的关键字将分到单独的池中。
分配的值,第一个和第二个连接字符串有所不同。
using (SqlConnection connection = new SqlConnection(
"Integrated Security=SSPI;Initial Catalog=Northwind"))
{
connection.Open();
// Pool A is created.
}
using (SqlConnection connection = new SqlConnection(
"Integrated Security=SSPI;Initial Catalog=pubs"))
{
connection.Open();
// Pool B is created because the connection strings differ.
}
using (SqlConnection connection = new SqlConnection(
"Integrated Security=SSPI;Initial Catalog=Northwind"))
{
connection.Open();
// The connection string matches pool A.
}
非活动或空池的维护只需要最少的系统开销。
|
|
|---|
|
当出现故障转移等错误时,会自动清除池。 |