[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mason
Subject:    [Mason] Re: Problem with Apache
From:       Dennis Watson dwatson () cmpnet ! com
Date:       1999-07-30 6:21:39
[Download RAW message or body]

Hi,

I will take a guess that you are not passing the proper connect string to
the DBI->connect.  You should pass it a TNS alias as defined in the file
$ORACLE_HOME/network/admin/tnsnames.ora  

The string andromeda.cnt.pl looks like a host not a TNS alias.   The
reason it works when you execute it from the command line is that you
probably have TWO_TASK and/or ORACLE_SID environment variables set.  Why
don't you look at $DBI::errstr when the connect fails?  There is valuable
information in there.

Try this (untested) component:

<html>
<head></head>
<body>

<h1>OK</h1>

</body>
</html>
<%perl_init>
use DBI;

# Get Database connection
# Automatically die $DBI::errstr on error
$ENV{ORACLE_HOME}='/usr/local/oracle';
my $dbh = DBI->connect('dbi:Oracle:tns_alias', 'login', 'pass',
                       {RaiseError => 1, AutoCommit => 0});
</%perl_init>


Dennis Watson - dwatson@cmpnet.com
Sr. SW Engineer CMP Media Inc.
BYTE Online Perl Columnist - http://www.byte.com


On Fri, 30 Jul 1999, Andrew J Bromage wrote:

> G'day all.
> 
> On Wed, 28 Jul 1999, Rafał Jank wrote:
> > The entire component looks like that:
> > 
> > <html><head></head><body><table>
> > <%perl>
> > use DBI;
> > $ENV{ORACLE_HOME}='/usr/local/oracle';
> > my $dbh=DBI->connect('dbi:Oracle:andromeda.cnt.pl','login','pass');
> > if (!$dbh){
> >  mc_out("Connection failed!");
> >  return;
> > }
> > </%perl>
> 
> Here's my test component:
> 
> <html>
> <head></head>
> <body>
> <%perl>
> use DBI;
>  
> $ENV{'ORACLE_HOME'}='/usr/oracle/product/8.1.5';
>  
> my $driver = 'Oracle';
> my $database = 'some_database_name';
> my $db_host = 'host.of.database.server';
> my $username = 'some_username';
> my $password = 'some_password';
>  
> my $dbh = DBI->connect(
>         "DBI:$driver:$database",
>         $username, $password
> );
> if ($dbh) {
>         mc_out("Connected OK");
> }
> else {
>         mc_out("Can't connect: $DBI::errstr");
> }
> </%perl>
> </body>
> </html>
> 
> Works fine for me.  What does $DBI::errstr report when you fail to connect?
> 
> Cheers,
> Andrew Bromage
> ======================================================================
> To unsubscribe: echo unsubscribe | mail mason-request@netizen.com.au
> Charter/FAQ/Archive: http://www.netizen.com.au/resources/lists/mason/
> 
> 
======================================================================
To unsubscribe: echo unsubscribe | mail mason-request@netizen.com.au
Charter/FAQ/Archive: http://www.netizen.com.au/resources/lists/mason/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic