Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   DB2 odbc unter Linux (https://www.delphipraxis.net/192377-db2-odbc-unter-linux.html)

Union 13. Apr 2017 08:27

DB2 odbc unter Linux
 
Hat das jemand bereits zum Laufen gebracht? In der 64-bit Windows Variante funktioniert es, bei Linux kommt es zu Fehlern bei der Initialisierung:

Code:
Im Projekt hello ist eine Exception der Klasse EODBCNativeException mit der Meldung '[FireDAC][Phys][ODBC][IBM][CLI Driver] CLI0133E Option type out of range. SQLSTATE=HY092' aufgetreten.
Zugriff über die IBM CLI db2 funktioniert.


Delphi-Quellcode:
program hello;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils,
  Data.DB,
  FireDAC.Stan.Def,
  FireDAC.Phys.DB2,
  FireDac.Comp.Client,
  FireDAC.Stan.Consts,
  System.IOUtils;

var
  Connection : TFDConnection;
  Link      : TFDPhysDB2DriverLink;
begin
  {$ifdef LINUX}
  Link := TFDPhysDB2DriverLink.Create(nil);
  Link.VendorHome := TPath.Combine(TPath.GetHomePath, 'sqllib/lib64');
  Link.VendorLib := 'libdb2.so';
  writeln(Link.VendorHome);
  {$endif}
  Connection := TFDConnection.Create(nil);
  try

    Connection.Params.DriverID             := 'DB2';
    Connection.Params.Values['Server']     := '<xx.xxx.xx.xx>';
    Connection.Params.Values['Port']       := '50000';
    Connection.Params.Values['Protocol']   := 'TCPIP';
    Connection.Params.Values['Database']   := '<dbname>';
    Connection.Params.Values['User_Name']  := '<user>';
    Connection.Params.Values['Password']   := '<password>';

    Connection.Connected := True;
    writeln('Connected');
    Readln;
  except
    on E: Exception do
      writeln(E.ClassName, ': ', E.Message);
  end;
  Connection.Free;
end.

Union 13. Apr 2017 09:31

AW: DB2 odbc unter Linux
 
Konnte es jetzt lösen. Der db2 Treiber dar nicht direkt geladen werden sondern über odbcunix.
Dazu waren folgende minmale einträge notwendig:

odbcinst.ini
Code:
[DB2]
Description=DB2 Driver
Driver=/home/<username>/sqllib/libdb2.so
FileUsage=1
DontDLClose=1
odbc.ini
Code:
[DB2]
Description=DB2 Test connection
Driver=DB2
Delphi-Quellcode:
Link.VendorHome := '/usr/local/lib';
Connection.Params.Values['DSN']        := 'DB2';


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:05 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz