1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
program loadlibdemo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
sysutils, Classes, sqldb,sqldblib,
pqconnection,
ibconnection,
mysql55conn,
mysql51conn,
mysql50conn,
mysql41conn,
mysql40conn;
Procedure List;
Var
S : TStringList;
I : Integer;
begin
S:=TStringList.Create;
try
getConnectionList(S);
Writeln('Available connection types:');
For I:=0 to S.Count-1 do
Writeln(S[i],', Default library name: ',GetConnectionDef(S[i]).DefaultLibraryName);
finally
S.free;
end;
end;
Procedure LoadLib(CT,LN : String);
Var
D : String;
begin
With TSQLDBLibraryLoader.Create(Nil) do
try
ConnectionType:=CT;
D:=LibraryName;
if (LN<>'') then
LibraryName:=LN;
Writeln('Loading library for connector',ct,' (default: ',D,', actual:', LibraryName,')');
try
LoadLibrary;
except
On E : Exception do
begin
Writeln('Error loading library : ',E.Message);
Exit;
end;
end;
Writeln('UnLoading library for connector',ct,' (default: ',D,', actual:', LibraryName,')');
try
UnLoadLibrary;
except
On E : Exception do
Writeln('Error unloading library : ',E.Message);
end;
finally
Free;
end;
end;
begin
if (ParamCount<1) or (paramcount>2) then
begin
Writeln('Usage : ');
Writeln('loadlibdemo list');
Writeln(' - lists all connection types');
Writeln('loadlibdemo conntype');
Writeln(' - Load default library for given connection type');
Writeln('loadlibdemo conntype libname');
Writeln(' - Load alternative library for given connection type');
end
else if (ParamStr(1)='list') then
List
else
LoadLib(Paramstr(1),ParamStr(2));
end.
|