-1
#!/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";

When I tried to execute the a.pl script to connect the database, I got the following errors:

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.

Then I tried to run perl -e 'use DBD::ODBC;' and got same error:

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 -e line 1. BEGIN failed--compilation aborted at -e line 1.

Can somebody help me to fix it?

vkk05
  • 3,137
  • 11
  • 25
  • 1
    Error clearly says you must install [DBD::ODBC](https://metacpan.org/pod/DBD::ODBC). – vkk05 Jun 23 '21 at 10:24
  • after found DBD-ODBC-1.61 setup package, then I get into the folder and run: perl Makefile.PL, it showed error as followed like this:[root@localhost DBD-ODBC-1.61]# perl Makefile.PL Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/lib64/perl5 /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 Makefile.PL line 21. BEGIN failed--compilation aborted at Makefile.PL line 21. – ghostcalvin Jun 24 '21 at 07:43

1 Answers1

0

You are missing the DBD::ODBC module. Use a tool to install the package from CPAN.

You can use the cpan executable or preferably cpanm:

$ cpan DBD::ODBC

Ricaz
  • 67
  • 5