如何在代码中设置DBX连接池? [英] How do I set up DBX connection pooling in code?

查看:159
本文介绍了如何在代码中设置DBX连接池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Delphi XE Professional。它带有大量的DBX东西,包括 DBXPool 单元,它包含连接池支持,但没有XE Enterprise附带的完整DBX支持。特别是很多设计时间支持并不存在。

I've got Delphi XE Professional. It comes with a fair amount of DBX stuff, including the DBXPool unit that contains the connection pooling support, but it doesn't have the full DBX support that comes in XE Enterprise. In particular, a lot of the design-time support isn't there.

我并不特别在意。没有连接,我就能做所有我需要的事情,直到需要连接池为止。现在,我试图使它起作用,但我还不太清楚如何使它起作用。我可以在程序中添加 DBXPool 并验证它是否已初始化,但是当我开始发出数据库请求时, TDBXPoolConnection.Create

I don't particularly mind that. I've been able to do all the stuff I've needed without it, up until I needed connection pooling. Now I'm trying to get that to work and I can't quite figure out how to make it work. I can add DBXPool to my program and verify that it initializes, but then when I start making database requests, TDBXPoolConnection.Create is never called.

这是我的连接设置代码,位于BeforeConnect事件处理程序中。有人知道我在做错什么以及如何正确处理吗?

Here's my setup code for the connection, in the BeforeConnect event handler. Anyone know what I'm doing wrong and how to get it right?

procedure TMyDataModule.connectionBeforeConnect(Sender: TObject);
begin
   connection.DriverName := 'Firebird';
   connection.Params.Values['User_Name'] := FUserName;
   connection.Params.Values['Password'] := FPassword;
   connection.Params.Values['Database'] := FDatabasePath;
   connection.Params.Values['ServerCharSet'] := 'UTF8';
   connection.Params.values['DelegateName'] := 'DBXPool';
   connection.Params.values['DelegateConnection.MaxConnections'] := '32';
end;

编辑::如果将来有人遇到这种情况并且同样的问题,这是我必须对其进行设置才能使其正常运行的方法。而不是上面的最后两行,

In case anyone comes across this in the future and has the same problem, here's how I had to set it up to make it work right. Instead of the last two lines above,

connection.Params.values['DelegateConnection'] := 'DBXPoolConnection';
connection.Params.values['DBXPoolConnection.DriverName'] := 'DBXPool';
connection.Params.values['DBXPoolConnection.MaxConnections'] := '32';

感谢Sertac将我带入正确的路线!

Thanks to Sertac for putting me on the right course!

推荐答案

您需要将 DBXPoolConnection 设置为 DelegateConnection 参数。

You need to set DBXPoolConnection to DelegateConnection parameter.

请参阅:连接池

这篇关于如何在代码中设置DBX连接池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆