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

    第一步:

       放一个TUniconnection并设置相关属性

    之后直接使用TUniconnection对象即可

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

    Connect方法调用CreateIConnection

    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
        if Pooling and FProvider.IsPoolingSupported then begin
          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);
    
            Connection := FProvider.GetConnectionPoolingManagerClass.GetConnection(
              ConnectionParameters, TUniSQLMonitor);
          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;
    

      

  • 相关阅读:
    printf函数实现的深入剖析
    rhel/centos播放mp3文件
    GRUB(GRand Unified Boot loader)引导加载程序
    NAT DHCP WWW rc.local
    论文 毕业设计 相关 用语 评语
    Linux禁止单用户模式(single)来增强系统安全
    Kernel command using Linux system calls
    GNU-ld链接脚本浅析
    AT&T汇编心得之间接寻址和LEA指令
    Linux 汇编语言开发指南
  • 原文地址:https://www.cnblogs.com/pengshaomin/p/4126662.html
Copyright © 2011-2022 走看看