procedure CreatePooledConnection;
var
oParams: TStrings;
begin
oParams := TStringList.Create;
try
oParams.Add('Server='+FServerName);
oParams.Add('Database='+FDatenbank);
oParams.Add('User_Name='+FUsername);
oParams.Add('Password='+FPassword);
oParams.Add('Port='+FPort.ToString);
oParams.Add('Pooled=True');
FDManager.AddConnectionDef(CONN_RAM_Pooled, 'MySQL', oParams);
FDManager.Active:=True;
finally
oParams.Free;
end;
We use a "PooledConnection" for this! And then in the Thread you only use this Pooled Connection for connecting to the Database, but you must create a new TFDConnection in every thread.
AConnection:=TFDConnection.Create(nil);
try
AConnection.ConnectionDefName:=CONN_RAM_Pooled;
try
AConnection.Connected:=true;
.....