Describes how to configure the AnyDAC DBMS drivers, including how to specify a DBMS client library. To link an AnyDAC driver to an application, specify DBMS client to the driver and other optional parameters, an application may use a TADPhysXXXDriverLink components and/or external configuration file.
To adjust a driver's behavior, you can use a driver configuration file or the TADPhysXXXDriverLink components. Most of the driver configuration file discussion also applies to the TADPhysXXXDriverLink components.
A driver configuration file is a standard INI text file. It may only be edited manually. Basically, the driver configuration file allows you to:
AnyDAC searches for the driver configuration file in the following places:
At design time, AnyDAC will use the file in the Delphi Bin folder or as specified in the registry.
If the section name in the driver configuration file is the base driver ID (for example, "ASA" or "Ora"), the base driver uses the parameter values specified in the corresponding section.
If the section name is not an ID of any of the base drivers (for example, "Ora815" or "MySQL510_Embedded"), AnyDAC registers a new virtual driver. The virtual driver uses the implementation of the base driver specified by the BaseDriverID parameter and the specified parameter values. A virtual driver ID then may be used as the value of the DriverID connection definition parameter. A virtual driver allows the application:
The following parameters may be specified:
|
Parameter |
Description |
Applied to Drivers |
|
VendorHome[ | Win32 | Win64 | MacOS32 | MacOS64 | UIX32 | UIX64] |
The Oracle Home name. |
Ora |
|
|
The base installation path. For example: C:\ib\ib2007. |
IB |
|
|
The base installation path for normal server. For example: C:\MySQL\MySQL5-1-7. Or the path to LIBMYSQLD.DLL for embedded server. For example C:\MyAPP\MySQL. |
MySQL |
|
VendorLib[ | Win32 | Win64 | MacOS32 | MacOS64 | UIX32 | UIX64] |
The DBMS client software API DLL name. For example: libmysql510.dll. |
|
|
ODBCDriver |
ODBC driver name. For example: Adaptive Server Anywhere 8.0. |
All ODBC based |
|
ODBCAdvanced |
ODBC driver additional parameters. The string consists of ODBC driver parameters separated by ?;?. Check the vendor documentation for possible values. |
All ODBC based |
|
EmbeddedArgs |
MySQL embedded server arguments. The string consists of MySQL server arguments separated by ?;?. Check the vendor documentation for possible values. For example: --datadir=./data;--language=./;--skip-innodb. |
MySQL |
|
EmbeddedGroups |
MySQL embedded server configuration file groups. |
MySQL |
|
NLSLang |
Oracle NLS_LANG environment variable value. |
Ora |
|
TNSAdmin |
Oracle TNS_ADMIN environment variable value. |
Ora |
For non-ODBC based drivers, if the VendorLib is specified, AnyDAC will use the specified DLL. If the VendorHome is specified, the DLL with default name from the Bin subfolder will be used. If none is specified, a DLL with a default name from:
will be used. Additionally may be specified a suffix, designating a platform.
For ODBC based drivers, if the ODBCDriver is specified, AnyDAC will use the specified driver. If it is not specified, a default driver name will be used.
[ASA] ; ASA base driver will use specified ODBC driver ODBCDriver=Adaptive Server Anywhere 8.0 [Ora815] ; Ora815 virtual driver will use specified Oracle Home BaseDriverID=Ora VendorHomeWin32=OraHome815 VendorHomeWin64=OraHome815_64 [MySQL327] ; MySQL327 virtual driver will use specified LIBMYSQL.DLL BaseDriverID=MySQL VendorLib=c:\LIBMYSQL327.DLL [MySQL510_Embedded] ; MySQL510_Embedded virtual driver will use specified MySQL embedded library and arguments BaseDriverID=MySQL VendorLib=c:\LIBMYSQLD.DLL EmbeddedArgs=--datadir=./data;--language=./;--skip-innodb;--skip-networking [MSSQL_2000] ; MSSQL_2000 virtual driver will use specified ODBC driver BaseDriverID=MSSQL ODBCDriver=SQL SERVER ODBCAdvanced= [FB21] ; FB21 virtual driver will use specified Firebird client library BaseDriverID=IB VendorLibWin32=C:\ib\fb21\bin\fbclient.dll VendorLibWin64=C:\ib\fb21_64\bin\fbclient.dll [FB21_Embedded] ; FB21_Embedded virtual driver will use specified Firebird client library BaseDriverID=IB VendorLib=C:\ib\fb21_embed\bin\fbembed.dll
You can also configure AnyDAC drivers in application code at runtime. To do that, drop the appropriate TADPhysXXXDriverLink components to your form. It has the same named properties as the parameters in the driver configuration file. The link component properties must be set before opening a first connection to a DBMS through this driver. The following code sample shows how to configure the Firebird driver at runtime:
interface uses ..., uADPhysIB; type TForm1 = class(TForm) ...... ADPhysIBDriverLink1: TADPhysIBDriverLink; ADConnection1: TADConnection; procedure FormCreate(Sender: TObject); ...... end; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin ADPhysIBDriverLink1.VendorLib := 'C:\ib\fb21_embed\bin\fbembed.dll'; ADConnection1.ConnectionDefName := 'IB_Demo'; ADConnection1.Connected := True; end;
When a connection using a driver was established and an application needs to switch to the other DBMS client:
The next connection using this driver will use the new link properties. The following code sample shows how to change the Firebird driver configuration at runtime:
ADConnection1.Close; ADPhysIBDriverLink1.Release; ADPhysIBDriverLink1.VendorLib := 'C:\fbclient.dll'; ADConnection1.Open;
Note: Although it is possible to use link components to configure drivers at design time, we do not recommend it, because it is hard to make that a module with a link component will be loaded before any other module with the AnyDAC components. So, the link component will configure the driver properly.
|
What do you think about this topic? Send feedback!
|