Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Errors connecting to Oracle via perl DBI

520855Jun 29 2006 — edited Jun 29 2006
Hi List.

I've installed Oracle on my linux box (SuSE 10) and I've installed
DBD::Oracle.

I can run sqlplus as the oracle user however when I try and connect via
DBD::Oracle in a perl script I always get errors as follows:

connect string =
my $dbh = DBI->connect("dbi:Oracle:ORCL", 'oracle', 'oracle' );

error =
DBI connect('ORCL','oracle',...) failed: ORA-12541: TNS:no listener (DBD
ERROR: OCIServerAttach) at ora1.pl line 7
Connection Failed...

connect string =
my $dbh = DBI->connect("dbi:Oracle:HOST=linux.site;SID=ORCL;PORT=1522",
'oracle', 'oracle' );

error =
DBI connect('HOST=linux.site;SID=ORCL;PORT=1522','oracle',...) failed:
ORA-12541: TNS:no listener (DBD ERROR: OCIServerAttach) at ora1.pl line 7
Connection Failed...



Maybe I have the connect string wrong?


Below is a listing of my code, and my tnsnames.ora:
Thanks in advance for your help.


############ code listing ################ #!/usr/bin/perl

use DBI;

print "Started\n";

my $dbh = DBI->connect("dbi:Oracle:HOST=linux.site;SID=ORCL;PORT=1522",
'oracle', 'oracle' );


if ($dbh) {
print "Connected...\n";
}
else {
print "Connection Failed...\n";
exit;
}

my $qry = $dbh->prepare("select count(*) from dba_tables");
$qry->execute();

my @data = $qry->fetchrow_array();

print "[$data[0]] [$data[1]] [$data[2]]\n";


exit;




######### tnsnames.ora listing #####################
# Generated by Oracle configuration tools.

LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux.site)(PORT = 1522))


ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux.site)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC2))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2006
Added on Jun 29 2006
1 comment
1,875 views