TFDManager and TFDConnection Questions

From RAD Studio
Jump to: navigation, search

Go Up to FAQ (FireDAC)

This topic contains a list of questions and answers related to TFDManager and TFDConnection.

Q1: I have a base data module class with TFDManager. When I create a descendant class, I get the 'Application must have only one FDManager' error. What is wrong?

A: You can only have one FDManager in an application. Instead of explicitly creating that in your classes, refer to a singleton object via FDManager function.

Q2: In my project group I have several different Delphi projects (applications), each with its own DataModule and FDManager. If I happen to open more than one of these data modules at the same time (to copy or compare items) then I get an error saying that you can only have one FDManager per application, and it promptly removes one of them from one of the data modules.

A: Do you really need TFDManager? An application does not need to explicitly create the TFDManager. It is required to set the options and the configuration files at design time.

Q3: I keep on loosing my FDManager's and have to recreate them. Can this be fixed?

A: No, this cannot be fixed because only one TFDManager may be created at design or run time. If there are several TFDManager's, then FireDAC will not know which one to use. Also see Q1.

Q4: Does FireDAC support a connection pooling?

A: Yes, it does. In general, connection pooling keeps a pool of open "physical" connections, and when TFDConnection.Connected is set to True, then FireDAC takes a "physical" connection from the pool and uses it. When TDDConnection.Connected is set to False, the "physical" connection is not closed, but put back into the pool.

To use the connection pooling in FireDAC, just add Pooled=True to you connection definition. No other special actions are needed. Read Multithreading for details.

Q5: Connection Editor seems to ignore FDPhysFBDriverLink1.VendorLib and uses hard-coded driver

A: You have to set VendorLib before the first connection using this driver. After a connection is established, the DBMS client is loaded.

At design time, to make sure that your TFDPhysXXXDriverLink properties are in usage, check that TFDPhysXXXDriverLink is first in the data module/form creation order. Then optionally restart Delphi IDE.

At run time, use the driver link Release method:

FDConnection1.Close;
...
FDConnectionN.Close;

FDPhysFBDriverLink.VendorLib := 'c:\fbclient.dll';
FDPhysFBDriverLink.Release;

FDConnection1.Open;
...
FDConnectionN.Open;

Another option is to define a virtual driver. For more details, see Configuring Drivers. For example:

[FB_Embedded]
BaseDriverID=FB
VendorLib = C:\fb\fbembed.dll

Use FB_Embedded driver as a DriverID at design time. At run time, you can also use FDDrivers.ini or just configure TFDPhysXXXDriverLink.