perl连接数据库出错

perl连接数据库出错

代码很简单,如下:
#!/usr/bin/perl -w
use DBI;
use strict;
my $dsn = $ARGV[0] if defined $ARGV[0];
my $conn = DBI->connect($dsn,"postgres","postgres" || die "Error $DBI::err [$DBI::errstr]";
printf "Connected: State is %s\n", $conn -> state || "OK";
$conn -> disconnect;

运行是报错:
install_driver(odbc) failed: Can't locate DBD/odbc.pm in @INC (@INC contains: /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl . /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/DBI/Const/GetInfo) at (eval 3) line 3.
Perhaps the DBD:dbc perl module hasn't been fully installed,
or perhaps the capitalisation of 'odbc' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Pg, Proxy, Sponge, mysql.
at perl-connect line 7

我后来安装了DBI-1.604.tar.gz,并且通过find命令找到有相应模块
[root@fedora9 usr]# find . -name "ODBC.pm"
./lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/DBI/Const/GetInfo/ODBC.pm
./lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/DBI/Const/GetInfo/ODBC.pm
这两个路径都在@INC中,不知道是我哪里搞错了,请高手帮忙指教一下,谢谢了!

还有我想问得就是装了DBI之后,默认支持的drivers只有DBM, ExampleP, File, Gofer, Pg, Proxy, Sponge, mysql么?其中Pg是指连接postgres的么?
哦。是不是因为我在linux上运行,所以根本就没有odbc这么一说啊? 呵呵
odbc是有的
路径不对是真的
系统将DBD:dbc
展开成DBD/odbc
你的路径不对
我后来导入路径BEGIN { push @INC, '/usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/DBI/Const/GetInfo' }也不对啊
Available drivers: DBM, ExampleP, File, Gofer, Pg, Proxy, Sponge, mysql.
这个是错误信息里面的一句话,貌似没有odbc也
还有打开你找到的所谓的odbc.pm
会有惊奇发现