我似乎无法编译并安装Firebird驱动程序以在Windows 10 64bit上运行的Strawberry Perl中使用。
我遵循的步骤包括:
下载并安装Strawberry Perl最新的32位驱动程序。
从控制台运行cpan
。
在cpan内部使用此install DBD::Firebird
该模块已下载并安装,但是连接到另一台Windows计算机上的Firebird数据库失败。
要连接的Perl代码如下:
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);
}
请有人能启发我如何连接到该数据库吗?
答案 0 :(得分:3)
我通常不使用Perl,但是由于一些试验和错误,我安装了DBD :: Firebird并做了一个保存为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";
}
如果我没有安装32位fbclient.dll
,则perl connect.pl
会导致错误:
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.
在安装32位fbclient.dll
之后,此方法有效(结果是Firebird附带的Employee示例数据库的COUNTRY
表):
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
要安装32位fbclient.dll,可以执行以下操作之一:
SysWoW64
文件夹(此文件夹包含32位客户端库),然后执行instclient i f
; instclient i f
。