2018-09-25 15:36:53 +02:00
|
|
|
unit FDConnectionConfigU;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
const
|
2018-09-28 18:33:19 +02:00
|
|
|
CON_DEF_NAME_FIREBIRD = 'MyConnFB';
|
|
|
|
CON_DEF_NAME_MYSQL = 'MyConnMYSQL';
|
2018-09-25 15:36:53 +02:00
|
|
|
|
2018-09-28 18:33:19 +02:00
|
|
|
procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean);
|
|
|
|
procedure CreateMySQLPrivateConnDef(AIsPooled: boolean);
|
2018-09-25 15:36:53 +02:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.Classes,
|
2018-10-14 18:23:20 +02:00
|
|
|
System.IOUtils,
|
2018-09-25 15:36:53 +02:00
|
|
|
FireDAC.Comp.Client;
|
|
|
|
|
2018-09-28 18:33:19 +02:00
|
|
|
procedure CreateMySQLPrivateConnDef(AIsPooled: boolean);
|
|
|
|
var
|
|
|
|
LParams: TStringList;
|
|
|
|
begin
|
|
|
|
LParams := TStringList.Create;
|
|
|
|
try
|
|
|
|
LParams.Add('Database=activerecorddb');
|
|
|
|
LParams.Add('Protocol=TCPIP');
|
|
|
|
LParams.Add('Server=localhost');
|
|
|
|
LParams.Add('User_Name=root');
|
|
|
|
LParams.Add('Password=root');
|
|
|
|
LParams.Add('TinyIntFormat=Boolean'); { it's the default }
|
|
|
|
if AIsPooled then
|
|
|
|
begin
|
|
|
|
LParams.Add('Pooled=True');
|
2018-10-14 18:23:20 +02:00
|
|
|
LParams.Add('POOL_MaximumItems=100');
|
2018-09-28 18:33:19 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
LParams.Add('Pooled=False');
|
|
|
|
end;
|
|
|
|
FDManager.AddConnectionDef(CON_DEF_NAME_MYSQL, 'MySQL', LParams);
|
|
|
|
finally
|
|
|
|
LParams.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean);
|
2018-09-25 15:36:53 +02:00
|
|
|
var
|
|
|
|
LParams: TStringList;
|
|
|
|
begin
|
|
|
|
LParams := TStringList.Create;
|
|
|
|
try
|
2018-10-14 18:23:20 +02:00
|
|
|
LParams.Add('Database=' + TPath.GetFullPath(TPath.Combine('..\..\..', 'data\ACTIVERECORDDB.FDB')));
|
2018-09-25 15:36:53 +02:00
|
|
|
LParams.Add('Protocol=TCPIP');
|
|
|
|
LParams.Add('Server=localhost');
|
|
|
|
LParams.Add('User_Name=sysdba');
|
|
|
|
LParams.Add('Password=masterkey');
|
|
|
|
if AIsPooled then
|
|
|
|
begin
|
|
|
|
LParams.Add('Pooled=True');
|
2018-10-14 18:23:20 +02:00
|
|
|
LParams.Add('POOL_MaximumItems=100');
|
2018-09-25 15:36:53 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
LParams.Add('Pooled=False');
|
|
|
|
end;
|
2018-09-28 18:33:19 +02:00
|
|
|
FDManager.AddConnectionDef(CON_DEF_NAME_FIREBIRD, 'FB', LParams);
|
2018-09-25 15:36:53 +02:00
|
|
|
finally
|
|
|
|
LParams.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|