uniGUI之FirDAC(13)

In uniGUI, each TFDConnection component must be placed on MainModule or a DataModule created from uniGUI Wizard. It is also possible to create and destroy a common datamodule as part of the constructor and destructor of any TUniForm (because they are also private to its session). This will ensure that each session will have its own private TFDConnection component.數據庫

在uniGUI,每一個TFDConnection組件必須放在 MainModule或者 由uniGUI Wizard建立的DataModule裏。TFDConnection也可建立和銷燬公衆 datamodule ,做爲 TUniForm(由於他們對Session一樣是私有的)的constructor 和destructor 。這將確保每一個Session將有它本身私有的TFDConnection組件。session

In addition to that, we need to place a TFDManager component on the ServerModule and set its Active property to True in ServerModule's OnCreate event.ide

另外,要放一個TFDManager組件在ServerModule ,在ServerModule的OnCreate 事件裏,設置它的Active 屬性爲True,。spa

Other components to place on ServerModule are TFDGUIxWaitCursor and TFDPhysXXXDriverLink. TFDPhysXXXDriverLink is the driver link component for your database engine. For MySQL it should be TFDPhysMySQLDriverLink. For TFDGUIxWaitCursor set Provider to Console and ScreenCursor to gcrNone. code

其餘要放在ServerModule 裏的組件有: TFDGUIxWaitCursor 和TFDPhysXXXDriverLink。TFDPhysXXXDriverLink是根據你的數據庫類型來的,例如,MySQL就應該爲TFDPhysMySQLDriverLink。將TFDGUIxWaitCursor的Provider 設置爲Console ,同時 ScreenCursor 設置爲gcrNone.。component

In the OnCreate event FDManager1.Active should be set to True.orm

FDManager1的OnCreate 事件裏, FDManager1.Active 應該設置爲True.blog

procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
begin
.
.
  FDManager1.Active := True;
end;

In similar manner, in the OnDestroy event FDManager1.Close should be called.事件

相似地,FDManager1的OnDestroy 事件,FDManager1.Close 應被調用。it

procedure TUniServerModule.UniGUIServerModuleDestroy(Sender: TObject);
begin
.
.
.
  FDManager1.Close;
end;

Pooling Connections 鏈接池

One of the advanced features in  FireDAC is the support for pooled connections. It allows sharing identical database connections among sessions.

FireDAC 的一個高級特點,就是它支持鏈接池。它容許在多個會話裏,共用同一個數據庫鏈接

相關文章
相關標籤/搜索