?
Solved

Database Connection from Perl

Posted on 2003-03-20
6
Medium Priority
?
179 Views
Last Modified: 2010-04-17
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
Comment
Question by:sehgaln
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 2

Accepted Solution

by:
Itatsumaki earned 200 total points
ID: 8177932
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
 
LVL 8

Expert Comment

by:adg080898
ID: 8180278
Try this:

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

my($dbh);

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

0
 
LVL 8

Assisted Solution

by:adg080898
adg080898 earned 400 total points
ID: 8180304
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
 

Expert Comment

by:CleanupPing
ID: 9446936
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
 
LVL 8

Expert Comment

by:adg080898
ID: 9448599
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question