The concept of a database connection pool is introduced in ADO.NET. In fact, the default we have used the database connection pool when connecting the database. such as
SqlConnection CONN
=
New
SqlConnection (); conn.connectionstring
=
"
Integrated Security = SSPI; Initial Catalog = PUBS
"
Conn.connectionString
=
"
Integrated security = SSPI; Initial Catalog = Pubs; POOLING = true; min pool size = 0; Max pool size = 100; connection reset = True
"
Conn.open ();
The effect of two database connection strings in the code is the same. It is to be said to enable the connection pool. The minimum time is 0, the maximum is 100. When each connection is completely reset, its context is reset. For this practice, there are a few things that are easy to misunderstood
1. The meaning of min pool size: assuming this place is changed to 50.
My early understanding: When the number of database connections does not exceed 50, it does not use the concept of the pool at all. That is to say, the line-shaped from 1 is gradually added to 50 as the user's new connection is gradually added to 50. After more than 50, start with the concept of pool. New connections reuse existing connections
As a result, this idea is wrong.
If my code is changed to
NEW SQLCONNECTION
"
Server = .; data = northwind; trusted_connection = yes; min pool size = 100
"
)
When the first user calls cnn.open, 100 connections of the result database initialize 100.
After looking at sp_who in the query analyzer, there were more than 100.
This is indeed unexpectedly.
Then I verified that the COM object pool is indeed in the first time it is constructed. Many objects are instantiated with min pool size.
Public
Class Customer
Class Customer Inherits ServicedComponent Sub New () Sub New () Dim eventLogEntry As New System.Diagnostics.EventLog ( "complus") eventLogEntry.WriteEntry ( "complus", "newed" & DateTime.Now) End Sub Protected Overrides Function CanBePooled () Function canbepooled () AS Boolean Return True End Functionend Class
As a result of the COM App Configure pool, you will write a log in the system log in the system log when the object is called.
Next time I will mention Connection Reset, this property is very affected. ;)