Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

Database Connection from Perl

I am using DBI, DBD:Oracle to connect to database through a perl script in cgi directory from Apache.
I am getting following error while I run the .cgi script...

[Thu Mar 20 17:07:55 2003] [error] [client 140.176.34.111] DBI connect('host=hostname;sid=orcl;port=1521','user','passwod') failed:  at C:/Program Files/Apache Group/Apache2/cgi-bin/test_db2_new.pl line 20
[Thu Mar 20 17:07:55 2003] [error] [client 140.176.34.111] Error:

I am using Apache web server 1.2 running on windows 2000 and my database is on HPUX.
0
sehgaln
Asked:
sehgaln
  • 3
2 Solutions
 
ItatsumakiCommented:
I need to see the exact DB connect code (remove the actual password & username of course!) to debug this.

I'll note that "password" is mispelled in the error message you gave, but that could be nothing.
0
 
adg080898Commented:
Try this:

my(@aDBILogin) = (
     'DBI:Oracle:__THEDATABASE__;host=__THEHOST__',
     '__THEUSERNAME__',
     '__THEPASSWORD__'
);

my($dbh);

$dbh = DBI->connect(@aDBILogin);
$dbh->{RaiseError} = 1;

0
 
adg080898Commented:
Or you might want to do this to see a proper error message:

-------------

# Install global exception handler
$SIG{__DIE__} = \&DeathHandler;

my(@aDBILogin) = (
    'DBI:Oracle:__THEDATABASE__;host=__THEHOST__',
    '__THEUSERNAME__',
    '__THEPASSWORD__'
);

my($dbh);

eval {
    $dbh = DBI->connect(@aDBILogin);
};
die($@ . "\nDBI-Error:" . DBI->errstr) if ($@);

$dbh->{RaiseError} = 1;

-------------
... OTHER CODE ...
-------------

# Global exception handler
sub DeathHandler {
     print "Content-type: text/html\n\n";
     print 'Error: ' . EscHTML($_[0]);
     exit;
}

-------------

I threw in the "die" handler code too as it seems you are not catching exceptions in your perl code.
0
 
CleanupPingCommented:
sehgaln:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
adg080898Commented:
He got two responses, one on the same day and one the day after. It's been 6 months with no response.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now