Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBD::ORACLE initialisation failed; can't locate object method "driver"

Status
Not open for further replies.

williey

Technical User
Jan 21, 2004
242
I received the following error when trying to perform a simple DB connect and disconnect to Oracle. Has anyone encounter similar problems? This is on a Win 2000 platform.
Reinstalling DBI package does not help.


DBD::ORACLE initialisation failed; can't locate object method "driver" via package DBD::ORACLE"


Code:
#!/usr/bin/perl

# db_test.pl

use strict;
use DBI;
use lib;


### Perform the connection using the Oracle driver

my $dbh = DBI->connect( "DBI:Oracle:dev01", "xxx", "xxx" )
    or die "Can't connect to Oracle database: $DBI::errstr\n";
 
### Now, disconnect from the database
$dbh->disconnect
    or warn "Disconnection failed: $DBI::errstr\n";
 
exit;
 
try

my $dbh = DBI->connect( "DBI:Oracle:eek:rcl", "xxx", "xxx" )

 
tried that but it does not work.
 
I looked in my book programming the perl DBI . the examples I looked at all have the lowercase dbi. worth a try I guess



my $dbh = DBI->connect( 'dbi:Oracle:eek:rcl',
'jeffry',
'jeffspassword',
);
 
that does not work too. I tried googling for the web but no posted the solution to their problems.
 
have you check all your envirment paths when you install the drivers you need to set paths. go to he perl web sit they give you specific instructions. has never failed me yet.

Brought to you By Nedaineum
The Portal to Geek-tum
 
This is Win 2000 based not one a Unix platform. The path to Oracle home is in the PATH env.
 
this is off the cuff but did you install the ODBC driver stuff?
 
Williey,
Added to what bitmite said check :
- is oracle client installed ? I think it is necessary;
- even, is DBD::Oracle installed, check your available modules.
Regards,
Zephan
 
Well.. I finally fixed the problem. Here is what I did.

1. Download a copy of the DBD::Oracle v1.15 source from CPAN.
2. Download a copy of the nmake 1.5 from Microsoft.
3. Make sure all the OCI files and lib are there. I have to copy from the missing files from the server to my machine.
\oracle\ora92\oci\lib\include\oratypes.h
\oracle\ora92\oci\lib \msvc\*.lib
4. I already have MS Visual Studio installed but I did run
C:\Program Files\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT
to make sure the environments path for the include and lib are set.
5. Set the ORACLE_HOME=\oracle\ora92
6. Build the Oracle.pm file using the following steps
perl Makefile.pl
nmake
nmake test (ignore the login errors)
nmake install
7. If you get the OCI initialization error 1031, double check your ORACLE_HOME path.
8. Run the following code to test your connection.

Code:
#!/usr/bin/perl

# db_test.pl

use strict;
use DBI;
use lib;


### Perform the connection using the Oracle driver

my $dbh = DBI->connect( 'DBI:Oracle:#oracle_sid#', '#user#', '#pass#' )
   or die "Can't connect to Oracle database: $DBI::errstr\n";

my $sql = qq( SELECT sysdate from dual );
my $sth = $dbh->prepare( $sql );
$sth->execute();
 
my $procdate;
$sth->bind_columns( undef, \$procdate );

while( $sth->fetch() ) {
  print "$procdate\n";
}

$sth->finish();

### Now, disconnect from the database
$dbh->disconnect or warn "Disconnection failed: $DBI::errstr\n";
 
exit;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top