Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

oracle DB connection from within a cgi-page

by Da_Mad_CoWw (Initiate)
on Nov 02, 2004 at 14:06 UTC ( #404596=perlquestion: print w/replies, xml ) Need Help??

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


Hi all,

I'm having a strange problem with a cgi page I wrote.
I think I know where the problem lies, but I'm getting a second opinion first :-)
Whenever I run the cgi from command-line the connection to the oracle db works fine.(listener runs at port 1521).
Whenever I run the script from a browser ( http://mysite.domain.be/cgi-bin/script.cgi) , then I get the folowing message : ORA-12154: TNS:could not resolve service name (DBD ERROR: OCIServerAttach) I have a hunch that the problem lies with the fact that the listener runs at port 1521 and the webpage at port 80 and that it's the firewall who's giving me a hard time, but i'm not sure.
Anyone any suggestions?

thx in advance

greetz
Da_Mad_CoWw
  • Comment on oracle DB connection from within a cgi-page

Replies are listed 'Best First'.
Re: oracle DB connection from within a cgi-page
by dragonchild (Archbishop) on Nov 02, 2004 at 14:06 UTC
    Do you have your ORACLE_HOME correctly set within the webpage? I would make sure that your environment is set correctly before debugging anything else.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: oracle DB connection from within a cgi-page
by edan (Curate) on Nov 02, 2004 at 14:11 UTC
Re: oracle DB connection from within a cgi-page
by etcshadow (Priest) on Nov 02, 2004 at 16:40 UTC
    Also, make sure that the database name can be found in your $ORACLE_HOME/network/admin/tnsnames.ora file (unless you're using some other kind of name resolution mechanism, like oranames server... which I doubt). By this I mean: your database connect probably looks something like:
    my $dbh = DBI->connect("dbi:Oracle:FOO", ...);
    In which case "dbi:Oracle:FOO" is called your "connect descriptor", and "FOO" is the database name (in oracle-speak, this is a "TNS name"). Anyway, you should be able to find the information needed to connect to your oracle database listed under FOO (or equivalent) in your $ORACLE_HOME/network/admin/tnsnames.ora file.

    Oh, and by the way: it's not a firewall issue. The error for that would be either hanging indefinitely on connect attempt or an error to the affect that the connection was refused. You are getting "could not resolve service name", which specifically means that the oracle client cannot figure out who you are trying to talk to (i.e. can't turn a TNS name into a: host, SID, and listener-port).

    Good luck.

    ------------ :Wq Not an editor command: Wq

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://404596]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2019-11-12 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (66 votes). Check out past polls.

    Notices?