#!/usr/bin/perl
use strict;
use DBI;
use warnings;
my $user = "database_user";
my $pass = "database_password";
my $server = "ip";
my $database_name = "db";
my $connectString = "driver={GBase ODBC 8.3 Driver};server=$server;database=$database_name;uid=$user;pwd=$pass";
my $dbh = DBI->connect("DBI:ODBC:$connectString")|| die "Connect failed: $DBI::errstr\n";
当我尝试执行a.pl脚本连接数据库时,出现以下错误:
install_driver(ODBC) failed: Can't locate DBD/ODBC.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 3) line 3.
Perhaps the DBD::ODBC perl module hasn't been fully installed,
or perhaps the capitalisation of 'ODBC' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
然后我尝试运行
perl -e 'use DBD::ODBC;'
并得到同样的错误:
在@INC 中找不到 DBD/ODBC.pm(@INC 包含: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) 在 -e 第 1 行开始。 失败——编译在 -e 第 1 行中止。
有人可以帮我解决吗?
在linux系统上,安装就可以了
perl -e'use CPAN; install "DBD::ODBC"'