Errors, Connecting to Oracle

Errors, Connecting to Oracle

am 29.06.2006 19:44:49 von Kevin

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)
)
)

RE: Errors, Connecting to Oracle

am 29.06.2006 19:49:17 von Ron.Reidy

From oerr:

$ oerr ora 12541
12541, 00000, "TNS:no listener"
// *Cause: The connection request could not be completed because the
listener
// is not running.
// *Action: Ensure that the supplied destination address matches one of
// the addresses used by the listener - compare the TNSNAMES.ORA entry
with
// the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is
to
// go by way of an Interchange). Start the listener on the remote
machine.

You have no listener installed or running.

--
Ron Reidy
Lead DBA
Array BioPharma, Inc.

-----Original Message-----
From: LLC [mailto:kevin@kevinkempterllc.com]=20
Sent: Thursday, June 29, 2006 11:45 AM
To: dbi-users@perl.org
Subject: Errors, Connecting to Oracle

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 =3D
my $dbh =3D DBI->connect("dbi:Oracle:ORCL", 'oracle', 'oracle' );

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

connect string =3D
my $dbh =3D =
DBI->connect("dbi:Oracle:HOST=3Dlinux.site;SID=3DORCL;PORT=3 D1522",
'oracle', 'oracle' );

error =3D
DBI connect('HOST=3Dlinux.site;SID=3DORCL;PORT=3D1522','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 =3D =
DBI->connect("dbi:Oracle:HOST=3Dlinux.site;SID=3DORCL;PORT=3 D1522",
'oracle', 'oracle' );


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

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

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

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


exit;




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

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


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

EXTPROC_CONNECTION_DATA =3D
(DESCRIPTION =3D
(ADDRESS_LIST =3D
(ADDRESS =3D (PROTOCOL =3D IPC)(KEY =3D EXTPROC2))
)
(CONNECT_DATA =3D
(SID =3D PLSExtProc)
(PRESENTATION =3D RO)
)
)




This electronic message transmission is a PRIVATE communication which =
contains
information which may be confidential or privileged. The information is =
intended=20
to be for the use of the individual or entity named above. If you are =
not the=20
intended recipient, please be aware that any disclosure, copying, =
distribution=20
or use of the contents of this information is prohibited. Please notify =
the
sender of the delivery error by replying to this message, or notify us =
by
telephone (877-633-2436, ext. 0), and then delete it from your system.