zoukankan      html  css  js  c++  java
  • Firedac 数据连接池的应用

    procedure TForm2.Button1Click(Sender: TObject);
    begin
      if not FDConnection1.Connected then
        FDConnection1.Connected := True;
    //  FDQuery1.SQL.Text := 'select getdate()';
      FDQuery1.Open('select getdate()');
      Caption := FDQuery1.Fields[0].AsString;
      //FDQuery1.Close;
      FDConnection1.Connected := False;
    end;
    
    procedure TForm2.FormCreate(Sender: TObject);
    var
      Def: IFDStanConnectionDef;
    begin
      Def := FDManager1.ConnectionDefs.FindConnectionDef('PoolTest');
      if Def=nil then
        Def := FDManager1.ConnectionDefs.AddConnectionDef;
      Def.Name := 'PoolTest';
      Def.Params.DriverID := 'mssql';
      Def.Params.Values['Server'] := 'JJW-PC';
      Def.Params.Database := 'TJZFDB';
      Def.Params.UserName := 'sa';
      Def.Params.Password := 'Sa12345';
      Def.Params.Pooled := True;
      Def.MarkPersistent;
      Def.Apply;
    
      FDConnection1.ConnectionDefName := 'PoolTest';
    end;

    经测试,动态添加连接池在第一次里有延迟,第二次就很多了,事件探查器中发现,多次点击button,最多只有2个连接。
  • 相关阅读:
    UVA 10604 Chemical Reaction
    UVA 10635 Prince and Princess
    UVA 607 Scheduling Lectures
    Create Maximo Report
    安裝及配置Maximo Report步驟
    check blocking
    數據據類型縮寫
    .net
    poj3522
    poj1286
  • 原文地址:https://www.cnblogs.com/Jiaojiawang/p/4196624.html
Copyright © 2011-2022 走看看