⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udbfactory.pas

📁 用DELPH写的DAO访问模块.有连接池.应用了各种模块,把数据库操作
💻 PAS
字号:
{*******************************************************}
{                                                       }
{       数据库工厂对象基类                              }
{       通过该抽象工厂创建数据库实例                    }
{                                                       }
{       版权所有 (C) 2009 大道网络                      }
{                                                       }
{*******************************************************}
unit uDBFactory;

interface

uses
  Classes, uDBContext, uDatabasePublic;

type
  //数据库工厂对象基类
  TDBFactory = class(TPersistent)
  private
    fDbKind : TDBKind;
  protected
    function getDbKind : TDBKind;
    procedure setDBKind(pDbKind: TDBKind);
  public
    class function getDBFactory(pDbKind: TDBKind) : TDBFactory;
    function CreatDBContext :TDBContext;  virtual; abstract;
  published
    property DBKind : TDBKind read getDbKind write setDBKind;
  end;

implementation

uses
  uAccessFactory, uMssqlFactory, uOralceFactory;

{ TDBFactory }

//根据配置文件创建相应的数据库工厂
class function TDBFactory.getDBFactory(pDbKind: TDBKind) : TDBFactory;
begin
  case pDbKind of
    dbMSSQL:
      result := TMssqlFactory.Create;

    dbORACLE:
      result := TOralceFactory.Create;

    dbACCESS:
      result := TAccessFactory.Create;
    else
      result := nil;
  end;
end;

function TDBFactory.getDbKind: TDBKind;
begin
  result := fDbKind;
end;

procedure TDBFactory.setDBKind(pDbKind: TDBKind);
begin
  fDbKind := pDbKind;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -