Manage pooling connection

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
wau73
Posts: 1
Joined: Thu 28 Jul 2022 13:44

Manage pooling connection

Post by wau73 » Thu 28 Jul 2022 14:11

Hi,
I am a new user of pdDAC and I wanted to understand how to manage a pooled connection with PosrgreSQL.
Reading the documentation I tried this code below ... but I don't understand if it is using a pool or not.

This code is inserted in a REST get ... resource of my REST server.
this code is called for every GET request

thanks for any help or advice
Antonello

--- Code

var
myConn: TPgConnection;
myQuery: TPgQuery;
begin

myConn := TPgConnection.Create(nil);
myQuery := TPgQuery.Create(nil);

try
myConn.ConnectString := 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
myConn.Pooling := true;
myConn.PoolingOptions.MaxPoolSize := 100;
myConn.PoolingOptions.PoolId := 1;

myQuery.SQL.Add('select * from public.messages');
myQuery.Connection := myConn;
myConn.Connect;

myConn.StartTransaction;
myQuery.ExecSQL;
myConn.Commit;

except
on E: Exception do
Res.send(E.message);
end;

Res.send(myQuery.RecordCount.ToString);

myQuery.Close;
myQuery.Free;
myConn.Disconnect;
myConn.Free;

evgeniym
Devart Team
Posts: 103
Joined: Thu 13 May 2021 07:08

Re: Manage pooling connection

Post by evgeniym » Mon 01 Aug 2022 09:43

Hi Antonello,
Thanks for contacting us!

Yes, you have set all parameters correctly.
You can find more information about the connection pool using the links:
https://docs.devart.com/pgdac/work_pooling.htm
https://docs.devart.com/pgdac/devart.da ... ooling.htm

An example of using the connection pool you can find in our demo:
"c:\Users\%UserName%\Documents\Devart\PgDAC for %IDEVersion%\Demos\Miscellaneous\FailOver"
where %UserName% is the username for which PgDAC is installed,
%IDEVersion% - IDE version for which PgDAC is installed

Post Reply