perl DBI、DBD-mysql、DBD-Oracle安裝

aaqwsh發表於2011-01-16

perl DBI:
安裝過程很簡單,下載解壓:

gzip -d DBI-1.604.tar.gz
tar xvf DBI-1.604.tar
cd DBI-1.604:
perl Makefile.PL
make
make test
make install

DBD-mysql:
rpm -ivh MySQL-devel-community-5.1.52-1.rhel5.i386.rpm
gzip -d DBD-mysql-4.006.tar.gz
tar xvf DBD-mysql-4.006.tar
 
perl Makefile.PL
make
make test
make install
 
DBD-Oracle:
 
cd DBD-Oracle-1.21
perl Makefile.PL
make
make test
make install
 
[oracle@node1 ~]$ perl  perora.pl
install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/DynaLoader.pm line 230.
 at (eval 3) line 3
Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at perora.pl line 17
 
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/lib
--需要用到一些動態庫
 
 
#!/usr/bin/perl -w
#2011-01-12
#use strict;
use DBI;
#use DBI qw(:sql_types);
$ENV{ORACLE_HOME} = "/data/ora10g/product/10.2.0/db_1";
$ENV{ORACLE_SID} = "RACDBSTD";
$ENV{LD_LIBRARY_PATH} = "/data/ora10g/product/10.2.0/db_1/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/lib";
$ENV{PATH} = "/data/ora10g/product/10.2.0/db_1/bin:/home/oracle/tools:/usr/sbin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/orac
le/bin";
 
#connect to postgresql database
my $dbh =DBI->connect( 'dbi:Oracle:RACDBSTD',
                        'test',
                        'test',
                        {
                          RaiseError => 1,
                          AutoCommit => 0
                        }
                      ) || die "Database connection not made: $DBI::errstr";
my $sql1 = qq{select name from tt};
my $sth1 = $dbh->prepare($sql1) ;
$sth1->execute();
my $rwcount = 0;
while( my @result1 = $sth1->fetchrow_array )
{
        print "$result1[0]\n";
}
$dbh->disconnect();

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-683947/,如需轉載,請註明出處,否則將追究法律責任。

相關文章