AnyDAC
ContentsIndexHome
PreviousUpNext
Configuring Drivers

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.

Group
Links
General

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. 

 

Driver configuration file

A driver configuration file is a standard INI text file. It may only be edited manually. Basically, the driver configuration file allows you to:

  • adjust parameters of a base driver (section name = base driver ID);
  • introduce a new virtual driver, which is a set of the base driver parameters saved under a new name (section name = new virtual driver ID).

AnyDAC searches for the driver configuration file in the following places:

  • ADDrivers.ini in the application EXE folder.
  • If the file above is not found, it looks for the file specified in the registry key HKCU\Software\da-soft\AnyDAC\DriverFile. By default, this is $(ADHome)\DB\ADDrivers.ini.

At design time, AnyDAC will use the file in the Delphi Bin folder or as specified in the registry. 

 

Base and Virtual Drivers

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:

  • to work with different versions of the DBMS client software in different connections, established in the same application run, for example to connect to Interbase and Firebird servers;
  • to choose an explicit version of the DBMS client software, for example to use one of the many LIBMYSQL.DLL's installed on workstation;
  • to set up drivers, which require parameters to be specified, for example MySQL Embedded server, which requires to specify arguments.

 

Driver Configuration Parameters

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. 
  • Ora
  • IB/FB
  • MySQL
 
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:

  • primary Oracle Home for Ora driver,
  • most left folder in PATH environment variable, containing the DLL, for other drivers

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. 

 

Sample driver configuration file content

 

[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

 

Configuring drivers in code

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:

  • close all connections on this driver;
  • call the driver link Release method;
  • change required link properties.

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!