Search found 1 match

by wau73
Thu 28 Jul 2022 14:11
Forum: PostgreSQL Data Access Components
Topic: Manage pooling connection
Replies: 1
Views: 8066

Manage pooling connection

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;