Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Connecting DBD::Oracle without using TCP/IP

by fx (Pilgrim)
on Dec 23, 2003 at 17:52 UTC ( #316665=perlquestion: print w/replies, xml ) Need Help??

fx has asked for the wisdom of the Perl Monks concerning the following question:

The DBD::Oracle documentation states that if your database resides on the same machine as your Perl code, then you can use a local IPC connector rather than TCP. My initial thought to this is that local IPC should be quicker.

The DBD::Oracle docs, however, do not cover Oracle 9i which is what I am using. The connection methods stated in the DBD::Oracle docs produce the error
DBI connect('','user',...) failed: ORA-06401: NETCMN: invalid driver designator (DBD ERROR: OCIServerAttach)
when I try running:

#!/usr/local/bin/perl BEGIN { $ENV{ORACLE_HOME} = '/app/oracle/product/9.0.1'; $ENV{TWO_TASK} = 'P:mydb'; } use DBI; $dbh = DBI->connect('dbi:Oracle:', 'user', 'pass') || die $!; $dbh->do("select 1 from dual"); $dbh->disconnect;

The DBD::Oracle docs suggest running $ORACLE_HOME/bin/adapters to make sure that the IPC adaptor is installed - mine is:

Installed Oracle Net Tranport Protocols are: IPC TCP/IP BEQueath SSL RAW

I did find a reference to a problem of this sort on Usenet but the article doesn't provide much help.

Can someone please suggest how I could connect to Oracle 9i with DBD::Oracle using something other than TCP/IP? If anyone has done this before, does a non-TCP/IP connection improve performance?

As you will be able to tell from my recent posts, I am having quite a lot of difficulty getting Oracle 9i to play nicely with Perl under my circumstances :)

Many thanks,

==fx, Infinity Is Colourless

Replies are listed 'Best First'.
Re: Connecting DBD::Oracle without using TCP/IP
by dragonchild (Archbishop) on Dec 23, 2003 at 18:16 UTC
    I would recommend emailing the DBD::Oracle mailing list and seeing what they say. My reading of the DBD::Oracle docs is that Oracle9i technically isn't supported. (It works, but hasn't been fully vetted yet.)

    We are the carpenters and bricklayers of the Information Age.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: Connecting DBD::Oracle without using TCP/IP
by Rhose (Priest) on Dec 23, 2003 at 19:15 UTC
    DBD::Oracle uses a TNS connect string to connect to the database. Depending on your Oracle client install the TNS names could be stored in a flat file called tnsnames.ora, on a names server, or in OID (Oracle internet directory) repository. Anyway, define a TNS name which will connect to the database in question and test the connection with SQL*Plus. Once you are able to connect with SQL*Plus, try connecting as below:

    $dbh = DBI->connect('dbi:Oracle:'.$TNS, $User, $Pass) || die $!;

    PLEASE take this with a grain of salt, as I only use TCP for connections to my databases. I played around with using the bequeath adaptor to connect to one of my test instances, and I added the following entry to the local tnsnames.ora file: = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = BEQ) (PROGRAM = oracle) (ARGV0 = oraclenboprd00) (ARGS = '(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=BEQ)))') ) ) (CONNECT_DATA = (SID = nboprd00)) )

    The ORACLE_SID of the database to which I was connecting is "nboprd00". To use this TNS name with the connection code above, set $TNS='beqtst';

    One other CYA, I did not test this with DBD::Oracle... I only tested it with SQL*Plus (I do not have DBD::Oracle installed on this test system, and I am not about to play with my install an hour before I leave for holiday. *Grins*)

Re: Connecting DBD::Oracle without using TCP/IP
by fx (Pilgrim) on Dec 28, 2003 at 20:24 UTC

    After a quick search on the Perl DBI mailing lists, I found a question and its answer which seems to be the solution to my problem.

    It would appear that if I want to use IPC then I need to configure a SID for the connection, but the answer that was provided cast doubt on whether IPC would be faster.

    If I can get it to work, perhaps I'll report my findings. Each run of my app updates 20,000 - 60,000 entries in a 6,000,000 record database over 6 tables so any small performance gain should be noticable.

Re: Connecting DBD::Oracle without using TCP/IP
by Nenad Noveljic (Initiate) on Oct 30, 2015 at 21:04 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://316665]
Approved by Thelonius
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (1)
As of 2023-06-08 06:23 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.