Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up DBX connection pooling in code?

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!

like image 631
Mason Wheeler Avatar asked Apr 18 '12 22:04

Mason Wheeler


1 Answers

You need to set DBXPoolConnection to DelegateConnection parameter.

See: Connection Pooling.

like image 174
Sertac Akyuz Avatar answered Sep 17 '22 18:09

Sertac Akyuz