Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

How to connect Oracle DB in Linux Env.

by pawank86 (Novice)
on Sep 09, 2011 at 12:49 UTC ( #925075=perlquestion: print w/replies, xml ) Need Help??

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

Hi All, I am trying to connect to ORACLE database using DBI module. The oracle DB is on Linux Env and i am trying to run the script for my system in window Env. I am using following code part to connect:
use DBI; my $dbh = DBI->connect("dbi:Oracle:host=","user", "passwo +rd");
After executing above code i am getting error : ORA-24327: need explicit attach before authenticating a user (DBD ERROR: OCISessionBegin). Please let me know if i am doing somthing wrong in this. Thanks in Advance..

Replies are listed 'Best First'.
Re: How to connect Oracle DB in Linux Env.
by Generoso (Prior) on Sep 09, 2011 at 13:30 UTC

    From your post I see missing either the SID or SERVICE and port elements on the connect parameters.

    my $dbh = DBI->connect('dbi:Oracle:host=localhost;sid=ORCL;port=1521', + 'scott', 'tiger', { RaiseError => 1, AutoCommit => 0 }); my $dbh = DBI->connect('dbi:Oracle:host=localhost;service=my.service.n;port=1521','scott', 'tiger', { RaiseError => 1, AutoCommit => + 0 });

      Hi Generoso, I tried the above code also but getting the same error of need explicit attach. I used SID = 'ORCL', DB port = 1521 and for host i used the IP address of Linux machine where DB is deployed, (machine which i want to connect). Please let me know other possible solutions.

        Have you tried to connect to the database via sqldeveloper form ORACLE it is free; you can downloaded and install it and set up a connection and test if the connecting parameters are the correct ones.

        Have not work with it on UNIX only in windows and is a good tool to debug your sql before you use it on a program or perl script

Re: How to connect Oracle DB in Linux Env.
by ww (Archbishop) on Sep 09, 2011 at 13:19 UTC
    You may find your answer in perldoc DBD::Oracle
Re: How to connect Oracle DB in Linux Env.
by marto (Cardinal) on Sep 09, 2011 at 13:23 UTC

    Can you connect to this database via sqlplus on Windows?

    Update: Whoops, see DBD::Oracle, providing the sid when connecting.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2022-05-18 17:08 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (71 votes). Check out past polls.