FireDac Pooling
1.建立FDManager的ConnectionDef。并设置此Pooling为True.
2.建立Thread类进行多个FDConnection连接DB。
3.本列是oracle远程数据.如下图:

Open pooling是建立FDManger中的Connection. Thread按钮是建立连接的测试。右边的空白是显示连接时间(为Ticks)
时间单位换算:
unit Unit1; interface uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Phys, Vcl.Buttons, FireDAC.Comp.Client, FireDAC.Stan.Pool,
FireDAC.Stan.Async, FireDAC.VCLUI.Wait, Data.DB, Vcl.StdCtrls,
FireDAC.Moni.Base, FireDAC.Moni.RemoteClient,FireDAC.DApt,
FireDAC.Phys.OracleDef, FireDAC.Phys.Oracle,System.Diagnostics; type TForm1 = class(TForm)
FDManager1: TFDManager;
SpeedButton1: TSpeedButton;
FDConnection1: TFDConnection;
BitBtn1: TBitBtn;
Memo1: TMemo;
FDMoniRemoteClientLink1: TFDMoniRemoteClientLink;
FDPhysOracleDriverLink1: TFDPhysOracleDriverLink;
procedure BitBtn1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; TDBThread=class(TThread)
private
FForm:TForm1;
FConn:TFDConnection;
FQry :TFDQuery;
procedure exePrc;
public
procedure Execute;override;
constructor Create(AForm:TForm1);
destructor Destroy;override;
end;
var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.BitBtn1Click(Sender: TObject);
var
i:integer;
ATrhed:TDBThread;
AStopWatch:TStopwatch;
j:Int64; begin
for i := to do //如果产生的Connection大于连接池的数量则会报错提示
begin
ATrhed:= TDBThread.Create(self);
end;
FDConnection1.ConnectionDefName :='oracle' ;
FDConnection1.LoginPrompt := false; //以下为不用连接池,时间就比较长
AStopWatch := TStopwatch.StartNew;
FDConnection1.Connected := true;
AStopWatch.Stop;
i:=AStopWatch.ElapsedTicks;
self.Memo1.Lines.Add('not pooling: '+j.ToString()+' Ticks'); end; procedure TForm1.SpeedButton1Click(Sender: TObject);
var
conn: IFDStanConnectionDef;
begin
FDManager1.Close;
conn:= self.FDManager1.ConnectionDefs.AddConnectionDef;
conn.Name :='ora_test';
conn.Params.DriverID :='Ora';
conn.Params.UserName :='admin';
conn.Params.Password :='pwd';
conn.Params.Database := 'testdb';
conn.Params.Pooled := True; //启用pool
conn.Params.PoolMaximumItems := ; //10.2.3中默认的最大池为50.一般够用
conn.Apply;//此方法可以不用
FDManager1.Open;//产生池
end; { TDBThread } constructor TDBThread.Create(AForm: TForm1);
begin
FreeOnTerminate := True;
FForm := AForm;
FConn := TFDConnection.Create(nil);
FQry := TFDQuery.Create(nil);
FQry.Connection := FConn;
FConn.ConnectionDefName := AForm.FDManager1.ConnectionDefs.ConnectionDefByName('ora_test').Name;//自动调用池,相当于FDmanager.AcquireConnection方法。最好按此列调用
inherited Create(false);; end; destructor TDBThread.Destroy;
begin
FConn.Free;
FQry.Free;
inherited;
end; procedure TDBThread.Execute;
begin
FQry.Close;
FQry.Open('select sysdate from dual');
Synchronize(exePrc);
end; procedure TDBThread.exePrc;
var
AStopWatch:TStopwatch;
i:Int64;
begin
AStopWatch := TStopwatch.StartNew;
FConn.Connected := True;
AStopWatch.Stop;
i:=AStopWatch.ElapsedTicks;
FForm.Memo1.Lines.Add('pooling: '+i.ToString()+' Ticks');
end; end.
运行结果:

FireDac Pooling的更多相关文章
- FIREDAC FDConnection 连接池 连接串
一.FDConnection 连接池 http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic ...
- 如何理解 卷积 和pooling
转自:http://blog.csdn.net/malefactor/article/details/51078135 CNN是目前自然语言处理中和RNN并驾齐驱的两种最常见的深度学习模型.图1展示了 ...
- FireDAC 连接SQL Server一些要注意的地方
TFDConnection: FetchOptions.Mode 设置为fmAll, 返回全部结果, 否则默认只返回前50条, 效果与open以后再执行FetchAll一样 Specifies how ...
- win2008使用FireDac连接ORACLE数据库问题
2008上装DELPHI XE7,无论用FireDac 还是Ado都连不上ORACLE数据库 --------------------------- Debugger Exception Notifi ...
- FireDAC 连接access MDB数据库的方法
Use Cases Open the Microsoft Access database. DriverID=MSAcc Database=c:\mydata.mdb Open the Microso ...
- 谈谈pooling?
使用pooling的目的之一是获取一定的特征不变性,目前用的比较多的是Max..,非线性对于Deep的重要性不用多说,pooling是主要贡献之一,当然少不了relu类的激活函数.pooling还有一 ...
- TensorFlow中max pooling层各参数的意义
官方教程中没有解释pooling层各参数的意义,找了很久终于找到,在tensorflow/python/ops/gen_nn_ops.py中有写: def _max_pool(input, ksize ...
- FireDac 的RecordCount 相关测试 记录。
unit Unit4; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...
- pooling的原理与Python实现
本文首先阐述pooling所对应的操作,然后分析pooling背后蕴含的一些道理,最后给出pooling的Python实现. 一.pooling所对应的操作 首先从整体上对pooling有一个直观的概 ...
随机推荐
- CMU Bomblab 答案
室友拉我做的... http://csapp.cs.cmu.edu/3e/labs.html Border relations with Canada have never been better. ...
- 定时导出用户数据(expdp,impdp)
一 定时导出数据: #!/bin/bash############################################################################### ...
- 计算1-1/x+1/x*x
// algo1-1.cpp 计算1-1/x+1/x*x. #include<stdio.h> #include<sys/timeb.h> void main() { time ...
- a标签的download属性简介
最近在工作中需要一个前端直接下载静态文件的需求,之前有粗略的了解过a标签的download属性,通过download和href属性可以实现文件的下载. 简介 HTML <a> 元素 (或锚 ...
- MyEclipse中代码提醒功能
一:最近仔细研究了下spring mvc中的代码,自己在配置文件哪里来时出现问题,没有提醒,只好自己搜了下有关的信息.如下 window--->preferences---->java-- ...
- bzoj 1012 基础线段树
原题传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1012 今儿一天状态不好,都没怎么刷题..快下课了,刷道水题.... 裸的线段树 /*** ...
- 通过监测DLL调用探测Mimikatz
通过Sysmon的-l参数可以探测到DLL加载(ImageLoaded): REF: https://securityriskadvisors.com/blog/post/detecting-in-m ...
- mongoDB文档操作【增删改】
MongoDB 插入文档 文档的数据结构和JSON基本一样. 所有存储在集合中的数据都是BSON格式. BSON是一种类json的一种二进制形式的存储格式,简称Binary JSON. 插入文档 Mo ...
- Codeforces Round #469 Div. 2 A B C D E
A. Left-handers, Right-handers and Ambidexters 题意 \(l\)个左撇子,\(r\)个右撇子,\(a\)个两手均可.要组成一支队伍,里面用左手的人数与用右 ...
- pycharm设置 django模板语言
``` 参考:https://www.zhihu.com/question/65342278/answer/229993987 在setting-language&frameworks-pyt ...