我想在COM+启动的时候,就将数据库连接上,以后就不用再次去连接,可以直接取数据了。但我发现,还是每次都会连接一次。
我的连接是在Activate中写的,可能是缓冲池没有设置,但我不知道怎么设置,请各位知道的讲讲怎么设置COM+中的缓冲池?非常感谢!
我的连接是在Activate中写的,可能是缓冲池没有设置,但我不知道怎么设置,请各位知道的讲讲怎么设置COM+中的缓冲池?非常感谢!
解决方案 »
- OnTimer是否没有返回而重复执行
- Clistctrl问题
- socket一次接收到几次发送的请求,怎样处理?
- 关于socket服务器的开发.
- 在CListCtl中,我这样取图标的索引值,为什么总是0啊?为什么取不到3?
- 求救,请问如何在选择文件之后,原来的菜单消失,显示另一个菜单
- 那位大哥能介绍一下“银行/电信呼叫中心系统“?谢谢!!!
- dll release 编译问题
- 如何获得特定窗口中浮动菜单的指针。
- 将原来是Pocket PC2003(ARMV4)的代码改为Windows CE(x86)并用VS2005(vc++)编译出错:fatal error LNK1112,在线等...
- 小妹初学VC,请问一个简单问题??
- 大哥大姐!!帮帮我吧!
或是在每次Activate中判断,如果已连接过,就跳过!
Title: Enabling and Disabling Services for a Provider
URL: http://msdn.microsoft.com/library/en-us/vccore/html/vcconEnablingDisablingServicesForProvider.asp For your information, on my NT4 with SQL2000 the OLEDB_SERVICES for SQLOLEDB looks like:
HKEY_CLASSES_ROOT\CLSID\{0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}
OLEDB_SERVICES 0xffffffff2. If the Recordset objects to clients won't be used to update back to the database in the future, I strongly suggest you use disconnected Recordset by setting the ActiveConnection property of the Recordset to Nothing/NULL, thus make the connection released to the pool. There are also some caveats on how to leverage the pooling service properly in the Troubleshooting MDAC Pooling section of the article below.
Title: Pooling in the Microsoft Data Access Components
URL: http://msdn.microsoft.com/library/en-us/dnmdac/html/pooling2.asp3. If a connection is enlisted in an ongoing transaction, it won't be returned to the connection pooling for reuse. - 微软全球技术中心 VC技术支持
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款
(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。
为了为您创建更好的讨论环境,请参加我们的用户满意度调查
(http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp?key=(S,49854782))。
再在“组件服务”设置缓冲池大小。
请不吝指教!谢谢!
1、缓冲池的使用由COM+系统来自动控制,超时后,缓冲的资源才会消失。
你应该在Activate里连接资源,在Deactivate 里释放资源,资源释放后进入缓冲池,超过一定时间后如无人使用的话,资源才真正从缓冲池中释放。就是说你每次访问组件功能后都要立即释放资源(实际上COM+并不让你真正地释放掉)。第一次Activate里连接资源时需要时间,以后就会快得多。2、COM+组件是否使用缓冲池,在“组件服务”里设置。
我现在的作法和你说的是一样的,连接时,我在数据库服务器上也能看到连接数,
我用OleDB连接时,连接池是有作用的,但是,用Olap连接时,连接池一直没有作用,只要在Deactivate 里Close掉,第二次连接时,还是要再连接一次,说明已经真正被释放了。在数据库服务器上也能看到连接数的变化,确实已经Close了。
不知你有没有用过Olap连接,如果知道问题的解决方法,不胜感激!
因为 OLEDB_SERVICES 缺省(0xffffffff)都是允许资源缓冲的,OLE DB for OLAP provider services 应该是OLEDB_SERVICES的一种,所以我怀疑Olap目前还不支持资源缓冲。
一定要强用的话,可以试试SharedPropertyGroup的方式管理打开的资源
在每个组建构造时创建并打开一个数据库连接。
在IObjectContext::Activate的时候,获取这个Connection对象的ADOConnectionConstruction接口(注意,OLEView查看连接对象并没有暴露这接口),通过ADOConnectionConstruction对象的Session属性获得OLE DB会话对象的接口,然后把它加进当前事务。
然后IObjectContext::Deactivate的时候,则是把这个会话对象从当前事务中退出。
对于 automatic transaction enlistment当在OLEDB_SERVICES registry entry 设置好后,应该不用强行JoinTransaction
其实如果你在FinalConstruct的时候打开连接对象(Open方法),因为此时环境变量没有生效,所以你的当前连接并没有参与到COM+环境的事务中去,SetComplete,SetAbort对数据库的事务将无效。
我认为_Connection::Open可能是先检查有没有当前环境,是否参与事务,如果是的话,把该会话加进当前事务,否则,该会话没有事务。就跟我提供的那个例子Activate执行的一样。因为数据源对象是在FinalConstruct里面创建并打开的,所以它没有事务,就要在Activate方法里面把它加进COM+事务中。to black_fox(black_fox) :
有些事情不是绝对的,例如做一个组件,专门用来对网站访问的统计,也许它的Connection永远都很繁忙,这时候如果你不停的Open,Close,反而会消耗它更多的资源。
你说的文章出处?
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLAP Server\Server Connection Info\ServerConnectTimeout
没有ServerConnectTimeout这一项
另外,你说的文章出处能不能告诉大家?
产品 | 支持 | 搜索 | Microsoft 指南
主页 搜索 常见产品技术问答 下载 新闻组 联系我们
PRB: An Error Occurs When You Set a Connection Timeout From DSO (Q251280)--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft SQL Server OLAP Services version 7.0
--------------------------------------------------------------------------------
SYMPTOMS
For the initial release of Microsoft SQL Server OLAP Services, it is not possible to configure a connection timeout from Decision Support Objects (DSO). The default connection timeout is set to 15 seconds. So, if it takes longer than 15 seconds for a connection to go through, the connection will timeout from DSO. The error message that occurs from DSO or OLAP Manager in such a case is: Cannot open connection to olap server <servername> WORKAROUND
Microsoft has confirmed this to be a problem in SQL Server OLAP Services version 7.0. This problem has been corrected in U.S. Service Pack 2 for Microsoft SQL Server OLAP Services version 7.0. For information about how to download and install the latest SQL Server OLAP Services Service Pack, see the following Microsoft Web site: http://support.microsoft.com/default.aspx?scid=http%3a%2f%2fsupport.microsoft.com%2fview%2fdev.asp%3fID%3dhl%26amp%3bpg%3dsql.asp
For more information, contact your primary support provider. MORE INFORMATION
IMPORTANT : This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base: Q256986 Description of the Microsoft Windows Registry With the Microsoft SQL Server OLAP Services service pack 2, it is now possible to configure a connection timeout by using this registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLAP Server\Server Connection Info\ServerConnectTimeout
To configure a connection timeout:
Open the Registry Editor.
From the Edit menu, click Add Value . In the Add Value dialog box, enter ServerConnectTimeout in the Value Name text box. In the Data_Type drop-down listbox, select REG_DWORD . Specify the timeout value in seconds. NOTE : The default connection timeout has been increased to 30 seconds in service pack 2. It is possible to configure the connection timeout from OLE DB for OLAP ( DBPROP_INIT_TIMEOUT ) or Microsoft ActiveX Data Objects Multi-dimensional (ADOMD). Use the Connection string property, Connect Timeout . Since the error message that occurs from DSO is a generic error message, to pinpoint the cause of the failure you should make a connection from ADOMD (you can use the mdx sample application for this) and note the error message. If the error that occurs is:
The operation requested failed due to timeout.
you know that the problem is due to the connection timeout. Also, note that the default timeout for OLE DB for OLAP or ADOMD is still 15 seconds.
--------------------------------------------------------------------------------
Published Apr 20 2000 6:41AM Issue Type kbprb
Last Modifed Jun 11 2002 9:35AM Additional Query Words
Keywords kbOLAP700
--------------------------------------------------------------------------------
COMMENTS?
If you would like to briefly comment on this article, you can enter your res in the space below (up to 255 characters).
Submit Comments
发送 | 打印 | 帮助
? 2002 Microsoft Corporation 版权所有.保留所有权利 隐私声明 Microsoft 辅助功能
产品 | 支持 | 搜索 | Microsoft 指南
--------------------------------------------------------------------------------
免费下载
产品目录
辅助功能
选购指南
--------------------------------------------------------------------------------
BackOffice产品系列
开发工具
Office产品系列
Windows产品系列
--------------------------------------------------------------------------------
技术支持
企业顾问咨询服务
市场活动与讲座
认证与培训
选购指南
微软出版社
--------------------------------------------------------------------------------
搜索 microsoft.com/china
--------------------------------------------------------------------------------
微软(中国)主页
美国总部主页
MSN主页
--------------------------------------------------------------------------------
站点地图
与我们联系
注册个人信息
市场活动与讲座
认证与培训
微软出版社
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q251280
有
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLAP Server\Server Connection Info
但没有ServerConnectTimeout这一项
没有ServerConnectTimeout这一项就说明没有连接池了,你有没有装SqlServer SP2呢?
还没装SqlServer SP2