You can use a group of name-value pairs to configure the link pool as a link string. For example, you can configure whether the pool is valid (which is valid by default). The maximum and minimum capacity of the pool is used
The time when the open link queue request is 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
Application allowed in connection poolProgramObtain a connection from the connection pool and use the connection, without re-establishing a connection for each connection request. Once a new connection is created
And placed in the connection pool, the application can reuse this connection without the entire database connection creation process.
When an application requests a connection, the connection pool allocates a connection for the application instead of creating a new connection. After the application uses the connection, the connection is returned to the connection.
Pool instead of directly releasing.
How to Implement connection pool
Make sure that each connection uses the same connection string (the same as the connection pool); only the connection pool with the same connection string will work. If the connection strings are different, the application
Instead of using the connection pool, you can create a new connection.
Advantages
The main advantage of using a connection pool is performance. The time required to create a new database connection depends mainly on the speed of the network and
(Network) distance, and this process is usually a very time-consuming process. After the database connection pool is used, the database connection request can be directly met through the connection pool without the need
Request to reconnect and authenticate to the database server, thus saving time.
Disadvantages
There may be multiple unused connections in the database connection pool that have been connected to the database (this means a waste of resources ).
Tips
1. Create a connection pool only when you need a database connection, instead of creating a connection pool in advance. Once you use the connection, immediately close it. Do not wait until the Garbage Collector processes it.
2. Make sure that all user-defined transactions are closed before closing the database connection.
3. Do not close all connections in the database. at least ensure that one connection in the connection pool is available. If memory and other resources are your first concern, you can disable all connections.
And then create a connection pool when the next request arrives.
Connection Pool FAQ
1. When to create a connection pool?
When the first connection request arrives, a connection pool is created. The connection pool is determined by the connection character creation of the database connection. Each connection pool is related to 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 retrieved from the connection pool. If not, a new connection pool is created.
2. When will the connection pool be closed?
Close the connection pool when all connections in the connection pool are closed.
3. When all connections in the connection pool are used up and new connection requests arrive, what will happen?
When the connection pool reaches its maximum number of connections, new connection requests are placed in the connection queue. When a connection is released to the connection pool
Newly released connections are allocated to connection requests queued in the queue. You can call close and dispose to return the connection to the connection pool.
4. How should I allow the connection pool?
For. NET applications, the connection pool is allowed by default. (This means that you don't have to do anything for it) Of course, if you can connect to the sqlconnection object
Add pooling = true to the string; Make sure that your application allows the use of the connection pool.
5. How should I disable the connection pool?
By default, ADO. Net allows a database connection pool. If you want to disable the connection pool, you can use the following method:
1) when using the sqlconnection object, add the following content to the connection string: Pooling = false;
2) When using the oledbconnection object, add the following content to the connection string: ole db services =-4;
From: http://bbs.yybug.com/read-htm-tid-18334.html