Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Mailing Lists -> Oracle-L -> RE: PERL DBI connection to Remote Oracle Database

RE: PERL DBI connection to Remote Oracle Database

From: Sanjay Mishra <>
Date: Wed, 29 Aug 2007 13:12:24 -0700 (PDT)
Message-ID: <>

Thanks Everybody. My earlier concern was that how it is working without PORT and that too not on default 1521 port. But when stefan pointed to check both Listener running on Remote Db Server, I found that it both Listener are servicing the Required Database. Actual Database listener is on Port 1523.    


"Lawie, Duncan" <> wrote:


  if you wish to connect to the listener on port 1523, put that in the connect string    

  $dbh = DBI->connect(";sid=ORCL;port=1523", $user, $passwd);    


  From: [] On Behalf Of Sanjay Mishra Sent: 28 August 2007 20:57
To: Stefan Knecht
Cc: oracle-l
Subject: Re: PERL DBI connection to Remote Oracle Database   


  Yes you are right that there are two listener Running. Listener 1521 show both db1 and DB2 even I am running different listener for DB2 with Port 1523.    

  So this might be the reason that perl script is working fine. If you see the document from Perl, it shows that it will also check for 1526. Is 1521 and 1526 are kind of default port if they are not specified.    


Stefan Knecht <> wrote:   You have 2 listeners ? One of them happen to listen on port 1521 ? Does the database in question show up if you query the services of that listener (lsnrctl serv <listener_name_on_port_1521>) -- perhaps the database registered itself on that listener without you knowing.


  On 8/28/07, Sanjay Mishra <> wrote: Ron    

  It is working and I am trying to understand as how it is making connection even the Port is not defined. On Remote DB server, I am running two listener. How this program use SID defined in Perl to connect to correct instance.         

"Reidy, Ron" <> wrote:

    My guess is it won't make a connection except for the default ports. What happens if you try it yourself with a small program?    

  Ron Reidy
  Lead DBA         

  From: [] On Behalf Of Sanjay Mishra Sent: Tuesday, August 28, 2007 8:42 AM
Subject: PERL DBI connection to Remote Oracle Database   


  I am working on exsiting Perl program and found that it is usinf DBI to connect to Remote Database . The string used to connect the Remote database doesn't have PORT. Connection is going fine. Remote database is listening on PORT 1523 and not the Default 1521.    

  I checked the Manual and it says the following but still not clear as if it only check on 1521 and 1526 or others. Any ideas as how it will work if Port is not specified like even shown below in the Doc statement   Connecting without environment variables or tnsname.ora file If you use the host=$host;sid=$sid style syntax, for example:

  $dbh = DBI->connect(";sid=ORCL", $user, $passwd);   then DBD::Oracle will construct a full connection descriptor string for you and Oracle will not need to consult the tnsname.ora file.   If a port number is not specified then the descriptor will try both 1526 and 1521 in that order ( e.g., new then old). You can check which port(s) are in use by typing "$ORACLE_HOME/bin/lsnrctl stat" on the server.    


Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
Received on Wed Aug 29 2007 - 15:12:24 CDT

Original text of this message