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 的一个高级特点,就是它支持链接池。它容许在多个会话里,共用同一个数据库链接

相关文章
相关标签/搜索