3

I cannot seem to get the Firebird driver compiled and installed for usage in Strawberry Perl running on Windows 10 64bit.

Steps I followed include:

  1. Download and install Strawberry Perl latest 32bit driver.

  2. run cpan from the console.

  3. Inside cpan use this install DBD::Firebird

  4. The module is downloaded and installed, however connecting to the Firebird database on another Windows machine fails miserably.

The Perl code to connect looks like:

sub IB_CONNECT {
    #database connection parameters
    use DBI;
    $dbname = 'db=192.168.0.12:c:/IXP220/Database/DB220.fdb';
    $user = 'SYSDBA';
    $password = 'masterkey';
    $firebirdDSN='dbi:Firebird:DRIVER={Firebird};' . $dbname;
    $dbhIB = DBI->connect($firebirdDSN,$user,$password);
}

Please can somebody enlighten me as to how to connect to this database?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Letholdrus
  • 1,261
  • 3
  • 20
  • 36
  • 1
    `DRIVER={Firebird};` doesn't look right. Get rid of that. – ikegami Jul 17 '19 at 09:47
  • 1
    `db=192.168.0.12:c:/...` doesn't match the docs, which use `host=192.168.0.12;db=c:/...` – ikegami Jul 17 '19 at 09:48
  • @ikegami Thanks for the info, it is most appreciated. I changed the code as per your suggestion. It is giving the following error now: `Can't connect to data source 'dbi:Firebird;db=192.168.0.12;c:/IXP220/Database/DB220.fdb' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at` – Letholdrus Jul 17 '19 at 09:52
  • huh, the code you showed did provide a "dbi:driver:" prefix (`dbi:Firebird:`) – ikegami Jul 17 '19 at 09:55
  • @ikegami In your first comment, aren't you telling me that it should be removed? – Letholdrus Jul 17 '19 at 09:57
  • Definitely not. I suggested trying to remove `DRIVER={Firebird};`, not `dbi:Firebird:`. (I suspect `DRIVER={Firebird};` is just silently ignored, not the cause of a problem.) – ikegami Jul 17 '19 at 09:58
  • @ikegami I see, thanks for clearing that up. That error now looks like `Can't connect to data source 'dbi:Firebird;db=c:/IXP220/Database/DB220.fdb;host=192.168.0.12' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at ../` – Letholdrus Jul 17 '19 at 10:01
  • 1
    The DSN consists of three **colon**-separated fields: The value of the first must be `dbi` (case-insensitive, I believe), the second is the name of the DBD module, and the third is data to be passed to the DBD module (in a DBD-specific format). Most DBD expect key=value pairs separated by semi-colons for the third field. /// For some reason, you appear to have replaced the colon with a semi-colon. Restore the colon (`dbi:Firebird:db=...;host=...`). – ikegami Jul 17 '19 at 10:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/196562/discussion-between-letholdrus-and-ikegami). – Letholdrus Jul 17 '19 at 10:13
  • 1
    did you install 32-bits "client libraries" of Firebird on this machine? – Arioch 'The Jul 17 '19 at 13:23

1 Answers1

4

I don't normally use Perl, but with some trial and error I installed DBD::Firebird and made a small test saved as connect.pl:

use DBI;

$dbh = DBI->connect("dbi:Firebird:db=employee;host=localhost", "sysdba", "masterkey");

$sth = $dbh->prepare("SELECT country, currency FROM country");

$sth->execute();

while ( @row = $sth->fetchrow_array ) {
  print "@row\n";
}

If I don't have the 32 bit fbclient.dll installed, then perl connect.pl results in an error:

install_driver(Firebird) failed: Can't load 'D:/DevSoft/Strawberry/perl/site/lib/auto/DBD/Firebird/Firebird.xs.dll' for module DBD::Firebird: load_file:The specified module could not be found at D:/DevSoft/Strawberry/perl/lib/DynaLoader.pm line 193.
  at (eval 8) line 3.
Compilation failed in require at (eval 8) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at connect.pl line 3.

With the 32 bit fbclient.dll installed, then this works (result is the COUNTRY table of the Employee example database included with Firebird):

USA Dollar
England Pound
Canada CdnDlr
Switzerland SFranc
Japan Yen
Italy Euro
France Euro
Germany Euro
Australia ADollar
Hong Kong HKDollar
Netherlands Euro
Belgium Euro
Austria Euro
Fiji FDollar
Russia Ruble
Romania RLeu

To install the 32 bit fbclient.dll, you can do one of the following:

  • Download and run the 32 bit installer for Firebird, and use the 'Minimum client install - no server, no tools' installation option;
  • If you already have a 64 bit Firebird installed on your machine, then open an Administrator Command Prompt, and go to the SysWoW64 folder of your Firebird install (this folder contains the 32 bit client library), and execute instclient i f;
  • Download and unzip the 32 bit Firebird zip kit, open an Administrator Command Prompt and go to the location of the unzipped zip kit, and execute instclient i f.
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • Thanks @mark-rotteveel registering the client dll using `instclient i f` did the trick! Your assistance is most appreciated. – Letholdrus Jul 22 '19 at 08:33