@@ -10,20 +10,21 @@ interface
1010 FireDAC.Comp.Client, FireDAC.Phys.PG;
1111
1212type
13+ TConnection = TFDConnection;
14+ TQuery = TFDQuery;
15+
1316 TDAC = class
1417 private
1518 FDriver: TFDPhysPgDriverLink;
16- FConnection: TFDConnection ;
17- FQuery: TFDQuery ;
19+ FConnection: TConnection ;
20+ FQuery: TQuery ;
1821 function GetDefaultLibDir : string;
1922 public
2023 constructor Create(aJSON: TJSONObject);
2124 destructor Destroy; override;
22- function getConnection : TFDConnection ;
23- function getQuery : TFDQuery ;
25+ function getConnection : TConnection ;
26+ function getQuery : TQuery ;
2427 function getConnectionStatus : string;
25- function getDataBases : TFDQuery;
26- function getTables (aDataBaseName: string): TFDQuery;
2728 end ;
2829
2930implementation
@@ -36,7 +37,7 @@ constructor TDAC.Create(aJSON: TJSONObject);
3637 FDriver.DriverID := ' PG' ;
3738 FDriver.VendorLib := GetDefaultLibDir;
3839
39- FConnection := TFDConnection .Create(nil );
40+ FConnection := TConnection .Create(nil );
4041 try
4142 with FConnection do
4243 begin
@@ -53,7 +54,7 @@ constructor TDAC.Create(aJSON: TJSONObject);
5354 if aJSON.GetValue(' schema' ) <> nil then
5455 ExecSQL(' SET search_path = ' + aJSON.GetValue(' schema' ).Value );
5556
56- FQuery := TFDQuery .Create(nil );
57+ FQuery := TQuery .Create(nil );
5758 FQuery.Connection := FConnection;
5859 FQuery.ResourceOptions.SilentMode := true;
5960 end ;
@@ -64,13 +65,13 @@ constructor TDAC.Create(aJSON: TJSONObject);
6465
6566destructor TDAC.Destroy;
6667begin
67- if Assigned(FDriver) then FreeAndNil(FDriver);
68- if Assigned(FQuery) then FreeAndNil(FQuery);
68+ if Assigned(FDriver) then FreeAndNil(FDriver);
69+ if Assigned(FQuery) then FreeAndNil(FQuery);
6970 if Assigned(FConnection) then FreeAndNil(FConnection);
7071 inherited ;
7172end ;
7273
73- function TDAC.getConnection : TFDConnection ;
74+ function TDAC.getConnection : TConnection ;
7475begin
7576 Result := FConnection;
7677end ;
@@ -100,11 +101,6 @@ function TDAC.getConnectionStatus: string;
100101 end ;
101102end ;
102103
103- function TDAC.getDataBases : TFDQuery;
104- begin
105-
106- end ;
107-
108104function TDAC.GetDefaultLibDir : string;
109105var
110106 DefaultDir: string;
@@ -114,17 +110,15 @@ function TDAC.GetDefaultLibDir: string;
114110 if FileExists(DefaultDir + ' \lib\libpq.dll' ) then
115111 Result := DefaultDir + ' \lib\libpq.dll'
116112 else if FileExists(DefaultDir + ' libpq.dll' ) then
117- Result := DefaultDir + ' libpq.dll' ;
113+ Result := DefaultDir + ' libpq.dll'
114+ else
115+ raise Exception.Create(' libpq.dll' +
116+ ' precisa estar na raiz do executável ou na pasta \lib\' );
118117end ;
119118
120- function TDAC.getQuery : TFDQuery ;
119+ function TDAC.getQuery : TQuery ;
121120begin
122121 Result := FQuery;
123122end ;
124123
125- function TDAC.getTables (aDataBaseName: string): TFDQuery;
126- begin
127-
128- end ;
129-
130124end .
0 commit comments