对象Pooling与数据库Pooling事实上毫无关联,
一个普遍的误解,是对象池化了,数据库连接也池化了,这是完全错误的!对象如果
调用结束,就应该马上把数据库连接释放!
这是delphi6帮助中对于关于Com+数据库Pooling的解释和使用方法
Opening and closing connections to a database can be time-consuming. By using a resource dispenser to pool database connections, your object can reuse existing database connections rather than create new ones. For example, if you have a database lookup and a database update component running in a customer maintenance application, you can install those components together, and then
they can share database connections. In this way, your applicationdo
es not need as many connections and new object instances can access the data more quickly by using a connection that is already open but not in use.
If you are using BDE components to connect to your data, the resource dispenser is the Borland Database Engine (BDE). This resource dispenser is only available when your transactional object is installed with MTS. To enable the resource dispenser, use the BDE administrator to turn on MTS POOLING in the System/Init area of the configuration.
If you are using the ADO database components to connect to your data, the resource dispenser is provided by ADO.
Note: There is no built-in resource pooling if you are using InterbaseExpress components for your database access.
For remote transactional data modules, connections are automatically enlisted on an object's transactions, and the resource dispenser can automatically reclaim and reuse connections.
这是delphi6帮助中对于Com+的object pooling的
Just as you can pool resources, under COM+ you can also pool objects. When an object is deactivated, COM+ calls the IObjectControl interface method, CanBePooled, which indicates that the object can be pooled for reuse. If CanBePooled is returns True, then
instead of being destroyed on deactivation, the object is moved to the object pool. It remains in the object pool for a specified timeout period, during which time it is available for use to any client requesting it. Only when the object pool is empty is a new instance of the object created. Objects that return False or thatdo
not support the IObjectControl interface are destroyed when they are deactivated.
Note: To take advantage of object pooling, you must use the 揃oth?threading model. For information on threading models, see Choosing a threading model for a transactional object.
Object pooling is not available under MTS. MTS calls CanBePooled as described, but no pooling takes place. If your object will only run under COM+ and you want to allow object pooling, set the object抯 Pooledproperty to True.
Even if an object抯 CanBePooled method returns True, it can be configured so that COM+do
es not move it to the object pool. If you install the transactional object under COM+ from the IDE, you can specify whether COM+ tries to pool the object using the COM+ page of the Type Library editor. Just select the object (CoClass) in the type library editor, go to the COM+ page, and check or uncheck the box for Object Pooling. Otherwise, a system administrator specifies this attribute using the COM+ Component Manager or MTS Explorer.
Similarly, you can configure the time a deactivated object remains in the object pool before it is freed If you are installing from the IDE, you can specify this duration using the Creation Timeout setting on the COM+ page of the type library editor. Otherwise, a system administrator specifies this attribute using the COM+ Component Manager.
这个难道还不清楚?