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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting ORA-12154: TNS:could not resolve service name 1

Status
Not open for further replies.

scriptdan

Technical User
Oct 11, 2004
15
US
Please help.

I have installed active state perl along with the DBD:DBI drivers for ORACLE via PPM.

I am able to SQLPLUS into the instance from the command prompt, but get a connection error when trying to connect to db. (see bottom of this post)

[blue]
Version Info
perl, v5.6.1 built for MSWin32-x86-multi-thread
Oracle9i Enterprise Edition Release 9.2.0.5.0
Class-DBI [0.96 ] Simple Database
Class-DBI-Oracle [0.51] Extensions to Class::DBI for Oracle
DBD-Oracle [1.12] Oracle database driver for the DBI module
DBIx-OracleLogin [0.02]
DDL-Oracle [1.11] a DDL generator for Oracle
[/blue]

Code:
#!C:\Perl\bin\perl.exe
push(@INC,"C:\Perl\site\lib");
print "@INC \n";

use strict;
use warnings;
use DBI;

my @drivers=DBI->available_drivers();
print join("\n",@drivers);
print "\n";

my $dbh = DBI->connect( 'dbi:Oracle:cms01',
                        'system',
                        'password',
                      ) || die "Database connection not made: $DBI::errstr";
$dbh->disconnect;

Script results:
[red]
C:/Perl/lib C:/Perl/site/lib . C:perlsiteib
ADO
DBM
ExampleP
File
ODBC
Oracle
Proxy

SybaseDBI connect('cms01','system',...) failed: at C:\CD_BURN\Perl DBI modules\MyScripts\OraTest.pl line 17
Database connection not made: ORA-12154: TNS:could not resolve service name (DBD: login failed) at C:\CD_BURN\Perl DBI modules\MyScripts\OraTest.pl line 17.
[/red]

 
I had been working on this a while. I just discovered my ORACLE_HOME variable was not being set.

I went to control panel settings to set the ORACLE_HOME environment variable for my machine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top