Recent

Author Topic: Zeos + Firebird  (Read 4770 times)

markus_ja

  • New Member
  • *
  • Posts: 43
Zeos + Firebird
« on: June 09, 2016, 10:37:26 am »
How can I set an absolute path in Connection.LibraryLocation in order to point to the installed firebird directory?

When I set an absolute path, e.g. C:\Program Files\Firebird\bin\fbclient.dll, the TZURL.SetURL function doesn't extract the LibLocation= properly. It interpretes the colon (:) in the path C:\.. incorrectly. It thinks the colon (:) specifies the host HostName.

If this is a bug, where should I report it?

Zoran

  • Hero Member
  • *****
  • Posts: 1643
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Zeos + Firebird
« Reply #1 on: June 09, 2016, 01:13:24 pm »
If you think this is Zeos bug, you can discuss it in their forum: http://zeoslib.sourceforge.net/
Or you can make bug report here: https://sourceforge.net/p/zeoslib/tickets/

JD

  • Hero Member
  • *****
  • Posts: 1818
Re: Zeos + Firebird
« Reply #2 on: June 09, 2016, 02:33:16 pm »
How can I set an absolute path in Connection.LibraryLocation in order to point to the installed firebird directory?

When I set an absolute path, e.g. C:\Program Files\Firebird\bin\fbclient.dll, the TZURL.SetURL function doesn't extract the LibLocation= properly. It interpretes the colon (:) in the path C:\.. incorrectly. It thinks the colon (:) specifies the host HostName.

If this is a bug, where should I report it?

I post below the code from a working 3 tier application I wrote. I don't use TZURL because I have an application server between the database and the client. The application server uses a connection pool and several connections are created when the application server is started as follows:

Code: Pascal  [Select][+][-]
  1. procedure TPoolHelper.OnCreateObject(Sender: TObject; var AObject: TObject);
  2. var
  3.   strFilePath, strDatabaseFullPath: string;
  4. begin
  5.   //
  6.   strFilePath         := ExtractFilePath(Application.ExeName);
  7.   strDatabaseFullPath := Copy(strFilePath, 0, Length(strFilePath) - 4) + 'data\MyFirebirdDatabase.fdb';
  8.   //
  9.   if not FileExistsUTF8(strDatabaseFullPath) then
  10.     MessageDlg(Format('The database %s does not exist.', [strDatabaseFullPath]), mtWarning, [mbOK], 0)
  11.   else
  12.     AObject := TServerData.Create(strDatabaseFullPath);
  13. end;
  14.  


The Create method that uses Zeos is as follows.

Code: Pascal  [Select][+][-]
  1. constructor TServerData.Create(TNSNAME: string; LOGIN_ID: string = 'sysdba';
  2.                         LOGIN_PW: string = 'masterkey';
  3.                         AHostName: string = '127.0.0.1';
  4.                         APort: integer = 0); overload;
  5. begin
  6.   //
  7.   inherited Create(nil);
  8.   //
  9.   F_TNSNAME := TNSNAME;
  10.   F_ID := LOGIN_ID;
  11.   F_PW := LOGIN_PW;
  12.   FHostName := AHostName;
  13.   //FPort := APort;               // disable for sqldb
  14.  
  15.   // Zeos method
  16.   //
  17.   with SQLConnection do
  18.   begin
  19.     // This is the default IP if the config file does not specify an alternative path
  20.     HostName                := AHostName;
  21.     // A zero hostname or HTTP Port #80. Zero if hostname is localhost and #80
  22.     // otherwise
  23.     Port                    := APort;
  24.     Database                := TNSNAME;
  25.     Protocol                := 'firebird-2.5';
  26.     User                    := LOGIN_ID;
  27.     Password                := LOGIN_PW;
  28.     AutoCommit              := False;
  29.     TransactIsolationLevel  := tiReadCommitted;
  30.  
  31.     // UTF-8 connection properties
  32.     with Properties do
  33.     begin
  34.       Add('character_set_client=utf8');
  35.       Add('character_set_connection=utf8');
  36.       Add('character_set_database=utf8');
  37.       Add('character_set_results=utf8');
  38.       Add('character_set_server=utf8');
  39.       Add('character_set_system=utf8');
  40.       Add('collation_connection=utf8_general_ci');
  41.       Add('collation_database=utf8_general_ci');
  42.       Add('collation_server=utf8_general_ci');
  43.       Add('Codepage=utf8');
  44.       Add('isc_tpb_concurrency');       // needed for multiuser environments
  45.       Add('isc_tpb_nowait');            // needed for multiuser environments
  46.     end;      // with Properties do
  47.  
  48.     try
  49.       // Connect to the database
  50.       // -- each connection in the pool will get its own direct connection to the
  51.       // -- database
  52.       Connect;
  53.     except
  54.       MessageDlg(strConnectionFailure, mtWarning, [mbOK], 0);
  55.     end;
  56.   end;
  57.  

Your application server can be something as simple as a Windows service or Linux daemon. This works for me. I hope it helps.

Cheers,

JD


Windows (10), Linux Mint - Lazarus 2.1/FPC 3.2, Delphi

Indy 10.6 series; mORMot; Zeos 7.3; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

 

TinyPortal © 2005-2018