我已经下载了IBM DBI软件包,包括文档中指定的程序中的所有软件包。我已经编目了数据库,可以从命令行连接到它,但是我的DBI连接失败了:
$dbh = DBI->connect ("dbi:DB2:warehou1", user, pass) or die "Can't connect to sample database: $DBI::errstr";
Can't connect to sample database: [IBM][CLI Driver] SQL1031N The database directory cannot be found on the indicated file system. SQLSTATE=58031
答案 0 :(得分:2)
当DBI无法解析简单数据库名称时,请考虑使用full connection string:
my $string = "dbi:DB2:DATABASE=$db; HOSTNAME=$hostname; PORT=$port; PROTOCOL=TCPIP; UID=$user; PWD=$pass;";
my $dbh = DBI->connect($string, $user, $pass) || die "Connection failed with error: $DBI::errstr";