zoukankan      html  css  js  c++  java
  • 使用Unidac内置连接池

    第一步:

       放一个TUniconnection并设置相关属性

    之后直接使用TUniconnection对象即可

    跟踪unidac源码uni单元1540行中可以看到

    Connect方法调用CreateIConnection

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    procedure TUniConnection.CreateIConnection;
    var
      Connection: TCRConnection;
      ConnectionParameters: TCRConnectionParameters;
     
      procedure SetSpecificObjectProps(SetAllProps: boolean);
      begin
        FProvider.SetObjectProps(Connection, FSpecificOptions.Values, SetAllProps);
        FSpecificOptions.IsModified := False;
      end;
     
    begin
      CheckProvider;
     
      Connection := FIConnection;
     
      if Connection = nil then begin
       <span style="color: #ff0000;"><strong> if Pooling and FProvider.IsPoolingSupported then begin</strong></span>
          ConnectionParameters := FProvider.GetConnectionParametersClass.Create;
          try
            ConnectionParameters.MinPoolSize := PoolingOptions.MinPoolSize;
            ConnectionParameters.MaxPoolSize := PoolingOptions.MaxPoolSize;
            ConnectionParameters.ConnectionLifeTime := PoolingOptions.ConnectionLifetime;
            ConnectionParameters.Validate := PoolingOptions.Validate;
            ConnectionParameters.Username := Username;
            ConnectionParameters.Password := Password;
            ConnectionParameters.Server := Server;
            ConnectionParameters.IOHandler := FIOHandler;
            ConnectionParameters.OnError := DoError;
            if FProvider.IsDatabaseSupported then //upd1
              ConnectionParameters.SetProp(prDatabase, FDatabase);
            if FProvider.IsPortSupported then
              ConnectionParameters.SetProp(prPort, Port);
     
            FProvider.SetObjectProps(ConnectionParameters, SpecificOptions, True);
     
          <span style="color: #ff0000;">  Connection := FProvider.GetConnectionPoolingManagerClass.GetConnection(
              ConnectionParameters, TUniSQLMonitor);</span>
          finally
            ConnectionParameters.Free;
          end;
        end
        else begin
          Connection := GetIConnectionClass.Create;
          Connection.IOHandler := FIOHandler;
          if FProvider.IsDatabaseSupported then
            Connection.SetProp(prDatabase, FDatabase);
          if FProvider.IsPortSupported then
            Connection.SetProp(prPort, Port);
        end;
     
        Connection.SetProp(prDisconnectedMode, Options.DisconnectedMode);
        Connection.SetProp(prEnableBCD, Options.EnableBCD);
      {$IFDEF VER6P}
      {$IFNDEF FPC}
        Connection.SetProp(prEnableFMTBCD, Options.EnableFMTBCD);
      {$ENDIF}
      {$ENDIF}
        Connection.SetProp(prDefaultSortType, Variant(Options.DefaultSortType));
        // if connection is just created we need to set all options
        SetSpecificObjectProps(True);
     
        SetIConnection(Connection);
      end;
     
      if FSpecificOptions.IsModified then
        SetSpecificObjectProps(False);
    end;

    http://www.cnblogs.com/pengshaomin/p/4126662.html

  • 相关阅读:
    小程序用户拒绝授权地理位置的处理办法
    云开发小程序数据库权限有限,通过云函数修改数据库评论信息
    小程序仿照微信朋友圈点击评论键盘输入
    小程序wx.previewImage查看图片再次点击返回时重新加载页面问题
    js手机端判断滑动还是点击
    Proxy
    Reflect.has检测对象是否拥有某个属性
    简单的axios请求返回数据解构赋值
    为windows terminal 配置 conda
    git clone 遇到问题:fatal: unable to access 'https://github.comxxxxxxxxxxx':
  • 原文地址:https://www.cnblogs.com/findumars/p/5321258.html
Copyright © 2011-2022 走看看