Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- From: johnson@xxxxxxxxxxxxxxxxxxxx (Bruce Johnson)
- Date: Tue, 29 Jul 2008 11:51:54 -0700
Perl 5.8, DBI 1.607, DBI::Oracle 1.21, Oracle 11g (11.1.0)
Any script I try to run results in the error:
Database connection not made: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor (DBD ERROR: OCIServerAttach) at ./testdbi.pl line 9.
This script works correctly on our old server running 8.1.6.
tnsping works, so I'm at a loss:
oracle@tonic2:/opt/lampp/logs> tnsping phmweb.pharmacy.arizona.edu
TNS Ping Utility for Linux: Version 11.1.0.6.0 - Production on 29- JUL-2008 11:34:53
Copyright (c) 1997, 2007, Oracle. All rights reserved.
Used parameter files:
/home/oracle/product/11.1.0/db_1//network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = tonic2.pharmacy.arizona.edu)(PORT = 1521))) (CONNECT_DATA = (SID = phmweb.pharmacy.arizona.edu)))
OK (0 msec)
The Oracle environment variables are set properly; sqlplus works just fine when invoked using the 'user'@'tnsname_of_server' login, another indication that TNSNames is working.
Here is the code I'm using:
#!/usr/bin/perl
use strict;
use DBI;
#$ENV{'ORACLE_HOME'}="/home/oracle/product/11.1.0/db_1";
#$ENV{'TNS_ADMIN'}="/home/oracle/product/11.1.0/db_1/network/admin";
sub PrintHeader {
return "Content-type: text/html\n\n";
}
my $dbh = DBI->connect( 'dbi:Oracle:phmweb.pharmacy.arizona.edu',
'people',
'password',
) || die "Database connection not made: $DBI::errstr";
my $sql = "select sysdate from dual";
my $ret = $dbh->prepare($sql);
$ret->execute();
print &PrintHeader;
#DBI::dump_results($ret);
my ($thedate);
$ret->bind_columns(\$thedate);
while(($thedate) = $ret->fetchrow_array) {print "Today's date is $thedate \n";}
$dbh->disconnect();
exit;
The ENV stuff was attempts to see if it was some environmental issue, this made no difference.
--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group
Institutions do not have opinions, merely customs
.
- Follow-Ups:
- Re: Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- From: Jeffrey Seger
- Re: Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- From: Bruce Johnson
- Re: Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- Prev by Date: Re: Perl+DBI question [NC]
- Next by Date: Re: Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- Previous by thread: Questions related to DBI and DBD::Oracle
- Next by thread: Re: Weird TNS error with DBI::Oracle 1.21 & oracle 11G
- Index(es):
Relevant Pages
|