DBX without deploying DBXDrivers.ini

By | November 26, 2010

After reading this blog posting I thought that there may be more people with the problem that DBX 4 makes it hard to deploy a database application without a DBXDrivers.ini file.

So here is a small unit that I wrote some years ago which allows me to connect to a local MySQL DB without the need of a DBXDivers.ini. (Delphi Professional is not for professionals but for starters. Otherwise the “only allowed to connect to local databases” limitation isn’t explainable. That’s why I mainly use the Zeos components instead of DBX to connect to a database)

If you want to connect to an other database vendor, you have to adjust the string literals in TDBXInternalProperties.Create and the driver name in the RegisterDriverClass(‘MySQL’, ..) call.

unit DBXMySQL;
 
interface
 
implementation
 
uses
  DBXCommon, DBXDynalinkNative;
 
type
  TDBXInternalDriver = class(TDBXDynalinkDriverNative)
  public
    constructor Create(DriverDef: TDBXDriverDef); override;
  end;
 
  TDBXInternalProperties = class(TDBXProperties)
  public
    constructor Create(DBXContext: TDBXContext); override;
  end;
 
{ TDBXInternalDriver }
 
constructor TDBXInternalDriver.Create(DriverDef: TDBXDriverDef);
begin
  inherited Create(DriverDef, TDBXDynalinkDriverLoader);
  InitDriverProperties(TDBXInternalProperties.Create(DriverDef.FDBXContext));
end;
 
{ TDBXInternalProperties }
 
constructor TDBXInternalProperties.Create(DBXContext: TDBXContext);
begin
  inherited Create(DBXContext);
  Values[TDBXPropertyNames.DriverUnit] := ''; // This is for the IDE only
 
  Values[TDBXPropertyNames.GetDriverFunc] := 'getSQLDriverMYSQL';
  Values[TDBXPropertyNames.LibraryName] := 'dbxmys.dll';
  Values[TDBXPropertyNames.VendorLib] := 'LIBMYSQL.dll';
 
  Values[TDBXPropertyNames.Database] := 'Database Name';
  Values[TDBXPropertyNames.UserName] := 'user';
  Values[TDBXPropertyNames.Password] := 'password';
 
  Values[TDBXPropertyNames.MaxBlobSize] := '-1';
end;
 
var
  InternalConnectionFactory: TDBXMemoryConnectionFactory;
 
initialization
  TDBXDriverRegistry.RegisterDriverClass('MySQL', TDBXInternalDriver);
  InternalConnectionFactory := TDBXMemoryConnectionFactory.Create;
  InternalConnectionFactory.Open;
  TDBXConnectionFactory.SetConnectionFactory(InternalConnectionFactory);
 
end.

11 thoughts on “DBX without deploying DBXDrivers.ini

  1. Nelson Henrique Corrêa Nepomuceno

    I think that Delphi Professional is for professionals!
    I use Delphi Pro since 1997 and I don´t need to use other versions. Maybe I am only starting with Delphi.
    I use third part dbx Drivers and can connect to databases as Client / Server and I don´t need to create 3 thier applications.

    1. Andreas Hausladen Post author

      Have your read the license_en.rtf file?

      4.4 ADDITIONAL LICENSE TERMS APPLICABLE TO PROFESSIONAL AND PROFESSIONAL ACADEMIC EDITIONS

      Subject to the terms and conditions of this License, Embarcadero grants to you as the licensed user of the Product the limited right to use that portion of the Product identified as “dbExpress”, in executable form only, to access a local database installed on the same machine as the Work. You may not use that portion of the Product identified as “dbExpress” in association with a database located on a different machine other than the machine on which the Works are installed.

  2. Jolyon Smith

    Great stuff Andreas – thanks for the suggestion. I shall look into this, tho it will need a bit of further tweaking to suit our needs I think (see my response in the comments on my own blog).

    As regards the archaic “no remote databases” access provision in the Professional license…

    Yes, it is stupid, dumb, ridiculous, antiquated etc etc. But it always was. Delphi Pro has always had this limitation, even under the days of the BDE>

    Borland never woke up to the fact that this simply drove people away from their DB technology to less restricted alternatives (when everyone can just use ADO, for example, putting such limits on alternative technologies does nothing except make them less attractive).

    The name over the door has changed, but the people in charge are – as we kept being told as if it were a good thing – so it really should be no surprise that dumb decisions made in the past are not just inherited but propogated by the current management.

      1. Michael Thuma

        Another INC from me too. The thing is with databases – the end user scenarios are more complex than the Enterprise scenarios. In the meanwhile the whole thing has changed…

        For me the picture presented is … who in the world today thinks that the work of a professional is in knowing the technological underlying … on Windows … not of interest. This adds no value in Business Software. It just leaves a bad taste …

  3. Yogi Yang

    Andy,

    You have mentioned Zeos in your post. I am just curious to know if you have updated it to work with XE.

  4. Natalie Vincent

    Hey Andy,

    Sorry for posting this into an unrelated topic, but I couldn’t find any other way to pass on a bug report to you on your site. BTW, thank you for your awesome work, it’s greatly appreciated and this isn’t a whinge or a complaint!

    When I use the Find Unit dialog in Delphi 2010 in a project with units with relative paths (specifically, relative paths to a sub directory under the project directory), and I try to use one of those units, an error occurs. Eg:

    Cannot open file “C:\Windows\system32\source\Unit1.pas”. The system cannot find the path specified.

    Where “source” is the folder under the project directory. The standard Delphi Use Unit dialog is then displayed.

    I am currently using DDevExtensions version 2.1, although this issue has been present for me for at least the last few versions of the add-in.

    Just thought I would pass it on, no reply required, and you can feel free to moderate this post out of this blog entry. 🙂

    Thank you again,

    N@
    Natalie Vincent

    1. Andreas Hausladen Post author

      I already know about this bug, but I didn’t had the time to reproduce it. And I’m not actively working on DDevExtensions till at least christmas.

Comments are closed.