How do I set up DBX connection pooling in code?

你。 提交于 2019-12-23 09:29:14

问题


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.

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.

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;

EDIT: 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';

Thanks to Sertac for putting me on the right course!


回答1:


You need to set DBXPoolConnection to DelegateConnection parameter.

See: Connection Pooling.



来源:https://stackoverflow.com/questions/10218813/how-do-i-set-up-dbx-connection-pooling-in-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!