我有一个问题,在重新编译和重新安装后,我无法让 Perl DBD::ODBC 使用 unixODBC。它以前安装过。
我已编译 DBD::ODBC 以使用 DataDirect ODBC 驱动程序管理器。我现在想重新编译它以使用 unixODBC。然而,尽管从新的源代码开始,配置(它选择 unixODBC),然后编译和安装,它似乎卡在使用 DataDirect ODBC 驱动程序管理器。我已经从 Perl 模块文件夹中删除了所有文件(我知道),但是重新安装时问题仍然存在。
我正在从源代码编译,因为我正在安装的服务器没有 Internet 连接,所以我没有使用 CPAN。
我在 Solaris 10 上使用 unixODBC 1.2.3 和 Perl 5.8.4(它与环境匹配)。
我已经删除了所有我能找到的:
1. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/
2. sudo rm -R ODBC
3. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/
4. sudo rm -R ODBC
5. sudo rm ODBC.pm
6. cd /usr/perl5/5.8.4/man/man3/
7. sudo rm DBD::ODBC.3
8. sudo vi /usr/perl5/5.8.4/lib/sun4-solaris-64int/perllocal.pod
然后我删除了 DBD::ODBC 中的所有条目perllocal.pod
。
当我运行它时,我可以看到perl Makefile.PL
它正在查找 unixODBC。
Looking for odbc_config at /usr/local/unixODBC_sp64/bin/odbc_config
Found odbc_config (via /usr/local/unixODBC_sp64/bin/odbc_config) version 2.3.2
odbc_config reports --prefix=/usr/local/unixODBC_sp64
odbc_config reports --include-prefix=/usr/local/unixODBC_sp64/include
odbc_config reports --lib-prefix=/usr/local/unixODBC_sp64/lib
ODBC INC dir set to /usr/local/unixODBC_sp64/include from odbc_config
ODBC LIB dir set to /usr/local/unixODBC_sp64/lib from odbc_config
Using ODBC HOME /usr/local/unixODBC_sp64
This looks like a unixodbc type of driver manager.
Looking for odbcinst
odbcinst -j reports:
unixODBC 2.3.2
DRIVERS............: /usr/local/unixODBC_sp64/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC_sp64/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC_sp64/etc/ODBCDataSources
USER DATA SOURCES..: /usr/local/unixODBC_sp64/etc/odbc.ini
这是我正在编译和安装模块的环境中与 ODBC 相关的所有环境变量
LD_LIBRARY_PATH=/usr/local/unixODBC_sp64/lib:
LD_LIBRARY_PATH_64=/usr/local/unixODBC_sp64/lib:
PATH=/usr/local/unixODBC_sp64/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/bin
ODBCINI=/usr/local/unixODBC_sp64/etc/odbc.ini
ODBCHOME=/usr/local/unixODBC_sp64
当我运行测试时,我仍然看到来自 DataDirect 驱动程序管理器的错误:
DBI connect('lksdjhf','ljkshdf',...) failed: [DataDirect][ODBC lib] System information file not found. Please check the ODBCINI environment variable. (SQL-IM002) at ./test_odbcdb2.pl line 19
忽略它找不到驱动程序的事实,因为没有填充 odbc.ini。我正在使用垃圾连接进行测试,因为我想从 unixODBC 看到同样的错误消息。
我用于测试的 Perl 脚本如下。它与 DataDirect 驱动程序管理器一起使用。
#!/usr/bin/perl -w
use DBI;
use DBD::ODBC;
use DBD::DB2::Constants;
print "Enter Data Source Name:";
my $dsn =<STDIN>;
chomp $dsn;
my $data_source = "DBI:ODBC:$dsn";
print "Enter Username:";
my $user =<STDIN>;
print "Enter password:";
my $password =<STDIN>;
chomp $user;
chomp $password;
# Connect to the db2 database using odbc
my $dbh = DBI->connect($data_source, $user, $password, {AutoCommit =>1})
or die "Can't connect to $data_source: $DBI::errstr";
$stmt = "SELECT current timestamp from sysibm.sysdummy1; ";
$sth = $dbh->prepare($stmt);
$sth->execute();
#associate variable with output columns...
$sth->bind_col(1,\$timestap);
while ($sth->fetch) {
print "The time is: $timestap\n";
}
$dbh->disconnect;