Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Error running CGI on tomcat

by sdeshpan (Initiate)
on Sep 10, 2007 at 22:27 UTC ( #638182=perlquestion: print w/ replies, xml ) Need Help??
sdeshpan has asked for the wisdom of the Perl Monks concerning the following question:

All,

I have been trying to run a CGI script on the tomcat app server by enabling CGI support through the configuration files in tomcat (on windows xp). I have been able to set up this configuration successfully and a sample "hello world" program works ok.

However, now I am trying to run my actual code, which connects to a DB using DBI, but it fails and gives me the following error:

Error ORA-12545: Connect failed because target host or object does not + exist (DBD ERROR: OCIServerAttach) connecting to DBI:Oracle:host=<ho +stname>;sid=<sid>;port=1521


As per WW's suggestion, here is the "connect" code that I am using:
# DBI Initializations my $driver = 'Oracle'; my $hostname = 'host=oradev;sid=oradev;port=1521'; my $user = 'user'; my $password = 'password'; my $dsn = "DBI:$driver:$hostname"; my $dbh = DBI->connect($dsn,$user,$password) or croak "Error $DBI::err +str connecting to $dsn\n";
I checked the TNSNAMES file and I am able to successfully ping and tnsping to the <hostname>. I wonder what might still be missing! Can anyone point me in the right direction?

Cheers,
Sarang D.

Comment on Error running CGI on tomcat
Select or Download Code
Replies are listed 'Best First'.
Re: Error running CGI on tomcat
by ww (Bishop) on Sep 11, 2007 at 00:59 UTC
    I suspect we'll need to see your connect code to be much help. Suggest you post it as an update within your OP.
      WW - I have posted the "connect" code in my post (original as well as a later one) already. Is that not what you were asking for?
Re: Error running CGI on tomcat
by rdfield (Priest) on Sep 11, 2007 at 09:14 UTC
    Can you connect using sqlplus?

    rdfield

      Yes, I can connect using sqlplus as well as toad. I can also ping the DB machine and tnsping is successful. This makes me believe that everything on the oracle client is ok. I am also providing the "connect" code here that I am using:
      # DBI Initializations my $driver = 'Oracle'; my $hostname = 'host=oradev;sid=oradev;port=1521'; my $user = 'user'; my $password = 'password'; my $dsn = "DBI:$driver:$hostname"; my $dbh = DBI->connect($dsn,$user,$password) or croak "Error $DBI::err +str connecting to $dsn\n";
      the last line is where it fails and gives me the error message!
        Does
        my $dsn = "DBI:$driver:oradev"; my $dbh = DBI->connect($dsn,$user,$password);
        make any difference?

        The code you currently have bypasses the tns alias, the code above uses the alias.

        rdfield

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2015-07-28 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls