日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

使用 TFDConnection 的 pooled 连接池

發布時間:2023/11/27 生活经验 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用 TFDConnection 的 pooled 连接池 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

從開始看到這個屬性,就一直認為他可以提供一個連接池管理功能, 苦于文檔資料太少, 甚至在幫助中對該屬性的使用都沒有任何介紹,如果你搜索百度,也會發現基本沒資料。

最后終于在其官方網站看到了其完整相關的英文資料,雖然沒有正面介紹該屬性,但卻是要啟用該屬性的詳細方法:

Defining Connection (FireDAC)

General

A?connection definition?is a set of parameters that defines how to connect an application to a DBMS using a specific FireDAC driver. It is the equivalent of a BDE alias, ADO UDL (stored OLEDB connection string), or ODBC Data Source Name (DSN). For the list of supported database management systems and corresponding parameters, see?FireDAC Database Connectivity.

FireDAC supports 3 connection definition kinds:

TypeDescriptionProsCons
PersistentHas a unique name, is managed by the FDManager, and is stored in a connection definition file.May be defined once and reused across many applications. May be pooled.The parameters (server address, DB name, and so on) are publicly visible and may be changed incidentally.

FDManager has to be reactivated or the Delphi IDE has to be restarted to make a newly added definition visible at design time.

PrivateHas a unique name, is managed by the FDManager, but is NOT stored in a connection definition file.Connection definition parameters are not visible "outside" the application. May be pooled.The application needs to create a private connection definition after each program restarts and cannot share it with the other programs.

Cannot be created at design time.

TemporaryHas no name, is not stored in a connection definition file, and is not managed by the FDManager.The simplest way to create a connection definition is to fill in the?TFDConnection.Params?property.

Can be created at design time using the TFDConnection component editor.

Similar to private. Also cannot be referenced by name and cannot be pooled.

Connection Definition File

The persistent connection definitions are stored in an external file - the?connection definition file. This file has the standard INI text file format. It can be edited by?FDExplorer?or?FDAdministrator?utilities at first, manually, or by code. By default the file is?C:\Users\Public\Documents\Embarcadero\Studio\14.0\FireDAC\FDConnectionDefs.ini.

Note: If you add a new persistent connection definition using FDExplorer or FDAdministrator while the RAD Studio IDE is running, it is not visible to the FireDAC design time code. To refresh the persistent connection definitions list, you need to reactivate FDManager or restart the RAD Studio IDE.

Sample content of this file:

[Oracle_Demo]
DriverID=Ora Database=ORA_920_APP User_Name=ADDemo Password=a MetaDefSchema=ADDemo ;MonitorBy=Remote ? [MSSQL_Demo] DriverID=MSSQL Server=127.0.0.1 Database=Northwind User_Name=sa Password= MetaDefSchema=dbo MetaDefCatalog=Northwind MonitorBy=Remote

An application can specify a connection definition file name in the?FDManager.ConnectionDefFileName?property. FireDAC searches for a connection definition file in the following places:

  • If ConnectionDefFileName is specified:
    • search for a file name without a path, then look for it in an application EXE folder.
    • otherwise just use a specified file name.
  • If ConnectionDefFileName is not specified:
    • Look for?FDConnectionDefs.ini?in an application EXE folder.
    • If the file above is not found, look for a file specified in the registry key?HKCU\Software\Embarcadero\FireDAC\ConnectionDefFile. By default it is?C:\Users\Public\Documents\Embarcadero\Studio\14.0\FireDAC\FDConnectionDefs.ini.
Note: At design time, FireDAC ignores the value of the?FDManager.ConnectionDefFileName, and looks for a file in a RAD Studio Bin folder or as specified in the registry. If the file is not found, an exception is raised.

If?FDManager.ConnectionDefFileAutoLoad?is?True, a connection definition file loads automatically. Otherwise, it must be loaded explicitly by calling the?FDManager.LoadConnectionDefFile?method before the first usage of the connection definitions. For example, before setting TFDConnection.Connected to?True.

Creating a Persistent Connection Definition

A persistent connection definition can be created using?FDExplorer?or?FDAdministrator. Here is how you can do that in code. Also see the demo FireDAC\Samples\Comp Layer\TFDConnection\ConnectionDefs.

The following code snippet creates a connection definition named "MSSQL_Connection", which has all parameters required to connect to the Microsoft SQL Server running locally, using the OS authentication (SSPI):

usesFireDAC.Comp.Client, FireDAC.Stan.Intf; var oDef: IFDStanConnectionDef; begin oDef := FDManager.ConnectionDefs.AddConnectionDef; oDef.Name := 'MSSQL_Connection'; oDef.DriverID := 'MSSQL'; oDef.Server := '127.0.0.1'; oDef.Database := 'Northwind'; oDef.OSAuthent := True; oDef.MarkPersistent; oDef.Apply; ..................... FDConnection1.ConnectionDefName := 'MSSQL_Connection'; FDConnection1.Connected := True;

FDManager is a global instance of the FireDAC connection manager. Its property?FDManager.ConnectionDefs: IFDStanConnectionDefs is a collection of the persistent and private connection definitions. The?AddConnectionDef?method adds a new connection definition. The?MarkPersistent?method marks a connection definition as persistent. The?Apply?method saves a connection definition to a connection definition file. Without the MarkPersistent call, the connection definition is private.

Creating a Private Connection Definition

A private connection definition can be created only in code. The code is similar to the one above, but without the MarkPersistent call.

Also, you can use a technique similar to BDE:

varoParams: TStrings;
beginoParams := TStringList.Create; oParams.Add('Server=127.0.0.1'); oParams.Add('Database=Northwind'); oParams.Add('OSAuthent=Yes'); FDManager.AddConnectionDef('MSSQL_Connection', 'MSSQL', oParams); ..................... FDConnection1.ConnectionDefName := 'MSSQL_Connection'; FDConnection1.Connected := True;

Creating a Temporary Connection Definition

A temporary connection definition can be created at design time using the FireDAC Connection Editor. In order to do this, double-click a TFDConnection to invoke the editor:

Or at run time in code by filling the?TFDConnection.Params?property. This is the simplest way to create a connection definition.

FDConnection1.DriverName := 'MSSQL'; FDConnection1.Params.Add('Server=127.0.0.1'); FDConnection1.Params.Add('Database=Northwind'); FDConnection1.Params.Add('User_name=sa'); FDConnection1.Connected := True;

Another option is to specify a connection string at run time by filling the?TFDConnection.ConnectionString?property. A connection string may be a convenient way to specify connection definition parameters for certain types of applications. For example:

FDConnection1.ConnectionString := 'DriverID=MSSQL;Server=127.0.0.1;Database=Northwind;User_name=sa'; FDConnection1.Connected := True;

Editing a Connection Definition

An application may need an ability to create and edit a connection definition at run time using standard FireDAC Connection Editor dialog. To edit a temporary connection definition stored in TFDConnection, use the code:

usesFireDAC.VCLUI.ConnEdit; ... if TfrmFDGUIxFormsConnEdit.Execute(FDConnection1, '') then FDConnection1.Connected := True;

To edit a connection definition represented as a FireDAC connection string, use the code:

usesFireDAC.VCLUI.ConnEdit; ... var sConnStr: String; ... sConnStr := FDConnection1.ResultConnectionDef.BuildString(); if TfrmFDGUIxFormsConnEdit.Execute(sConnStr, '') then begin FDConnection1.ResultConnectionDef.ParseString(sConnStr); FDConnection1.Connected := True; end;

轉載于:https://www.cnblogs.com/zhenfei/p/4105515.html

總結

以上是生活随笔為你收集整理的使用 TFDConnection 的 pooled 连接池的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日韩欧美视频二区 | 操伊人 | xiuxiuavnet | 天天操天天干天天摸 | 午夜剧场黄色 | 美女在线观看www | 国内自拍一区 | 国产精品成人午夜视频 | 最近最新中文字幕 | 少妇精品在线 | 亚洲激情短视频 | 深夜福利久久 | 91精品久久久久久久久中文字幕 | 催眠美妇肉奴系统 | 中文文字幕文字幕高清 | 天天曰天天操 | 中文字幕永久在线播放 | 色女人影院| 亚洲精品久久久久久国产精华液 | 精品国产福利 | 久久久久久久久久久久久久国产 | 国产精品久久久不卡 | 国产一区二区在线视频观看 | 欧美色悠悠 | 国产丰满农村老妇女乱 | 欧洲美熟女乱又伦 | 精品人妻一区二区三区三区四区 | 黄页网址大全免费观看 | 亚洲天堂网视频 | 亚洲一卡二卡三卡四卡 | 亚州激情视频 | 日本xxxxxxxxx69| 久久小草 | 午夜国产一区 | 精品少妇一区二区三区免费观 | avxx| 中国农村一级片 | 秋霞福利 | 欧美激情一区二区三级高清视频 | 欧美色老头old∨ideo | 日本黄色片段 | 不卡影院| 午夜黄色在线 | 亚洲高清自拍 | av在线入口 | 黄色性网站 | 樱花影院最新免费观看攻略 | 麻豆免费在线播放 | 黄色在线免费 | 国产婷婷色一区二区三区在线 | 国产大片中文字幕在线观看 | 亚洲天堂视频在线观看 | 桃谷绘里香在线播放 | 中国美女性猛交 | 日韩欧美三级视频 | 日韩精品视频在线播放 | 无码人妻精品丰满熟人区 | 成人先锋av | 久久久a级片 | 亚洲AV无码成人精品区在线观 | 日本性高潮视频 | 激情午夜影院 | 日韩欧美激情在线 | 一区二区伊人 | 日韩视频一区二区三区四区 | 啦啦啦视频在线观看 | 午夜视频免费观看 | 国产黄色成人 | 91精品国产自产精品男人的天堂 | 成人在线观看国产 | aⅴ在线免费观看 | 波多野结衣先锋影音 | 1024手机看片国产 | 99久久久无码国产精品免费蜜柚 | wwwwxxx日本| 黄色高清无遮挡 | 国产成人精品无码免费看81 | 黄色免费在线观看网站 | 综合久久91 | 日日骚一区 | 在线不卡日韩 | 国产成人免费在线 | 免费特级毛片 | 女人脱下裤子让男人捅 | 亚洲国产aⅴ精品一区二区的游戏 | www在线观看免费视频 | 国产一区不卡 | 岛国av免费 | 青青草这里只有精品 | 黄色avv | 99re6在线视频 | 国产精品77777 | 色欲av伊人久久大香线蕉影院 | 高清无码视频直接看 | 欧美日韩生活片 | 国产精品亚洲色图 | 成人av手机在线 | 天天燥日日燥 | 欧美成人高清在线 |