Http://www.cnblogs.com/wbcms/archive/2008/10/11/1308725.html
You can use a set of name-value pairs to configure the link pool as a link string. For example, you can configure whether the pool is valid (valid by default), the maximum and minimum capacity of the pool,
The time that the queued request for the open link was blocked. The following example string configures the maximum and minimum capacity of the pool.
"Server= (local); Integrated Security=sspi; Database=northwind;
Max Pool size=75; Min Pool size=5 "
Summary
Connection pooling allows applications to obtain a connection from the connection pool and use this connection without having to reestablish a connection for each connection request. Once a new connection is created
and placed in the connection pool, the application can reuse the connection without having to implement the entire database connection creation process.
When an application requests a connection, the connection pool assigns a connection to the application instead of re-establishing a connection, and when the application finishes using the connection, the connection is returned to the connection
Pool instead of being released directly.
How to implement a connection pool
Make sure you use the same connection string (the same as the connection pool) for each connection, and only the connection string will work when the connection pool is connected. If the connection string is not the same, the application
Instead of using a connection pool, you create a new connection.
Advantages
The main advantage of using connection pooling is performance. The time it takes to create a new database connection depends largely on the speed of the network and on the application and database server
(network) Distances, and this process is often a time-consuming process. With a database connection pool, database connection requests can be satisfied directly through the connection pool without needing to
To reconnect and authenticate to the database server, saving time.
Disadvantages
There may be multiple connections in the database connection pool that are not being used to connect to the database (which means a waste of resources).
Tips and Hints
1. When you need a database connection, create a connection pool instead of building it in advance. Once you're done using the connection, close it immediately, and don't wait for the garbage collector to handle it.
2. Ensure that all user-defined transactions are closed before closing the database connection.
3. Do not close all connections in the database, at least one connection in the connection pool is guaranteed to be available. If memory and other resources are issues that you must first consider, you can close all the connected
And then create the connection pool when the next request arrives.
Connection Pooling FAQ
1. When do I create a connection pool?
Creates a connection pool when the first connection request arrives, and the connection pool's establishment is determined by the connection word Fu Shilai of the database connection. Each connection pool is associated with a different connection string.
When a new connection request arrives, if the connection string is the same as the string used by the connection pool, a connection is taken from the connection pool, and if it is not the same, a new connection pool is created.
2. When do I close the connection pool?
Closes the connection pool when all connections in the connection pool have been closed.
3. What happens when a connection in the connection pool is exhausted and a new connection request arrives?
When a connection pool has reached its maximum number of connections, new connection requests are placed in the connection queue when a new connection request arrives. When a connection is released to the connection pool, the connection pool is
The newly released connection is assigned to the connection request that is queued in the queue. You can call close and Dispose to return the connection to the connection pool.
4. How should I allow connection pooling?
for. NET applications, the default is to allow connection pooling. (which means you don't have to do anything for this thing.)Of course, if you can connect the SqlConnection object
Add the Pooling=true to the string and make sure that your application allows connection pooling to be used.
5. How do I disable connection pooling?
Ado. NET defaults to allow database connection pooling, if you want to disallow connection pooling, you can use the following methods:
1) When using the SqlConnection object, add the following to the connection string: Pooling=false;
2) When using the OleDbConnection object, add the following to the connection string: OLE DB services=-4;