Hi, 

I have problems connecting to an Oracle-DB through apache2. A test
script, that works fine when run directly from the shell, fails to
connect to the Orcacle DB, when run through apache. As far as I can see,
the SID is not passed to the DB server. 

..................................... 
The foolowing message is found in the error log: 

[Thu Aug 15 09:25:46 2002] [error] 27824: ModPerl::Registry:
`DBI->connect(sun1) failed: Error while trying to retrieve text for
error ORA-12505 (DBD ERROR: OCIServerAttach) at
/server/apache-dev/perl/test-oracle line 23 
' 

....................................... 
the log file  of the Oracle listener on the DB box ahows: 


15-AUG-02 09:25:46 *
(CONNECT_DATA=(SID=*)(SERVICE_NAME=sun1.)(CID=(PROGRAM=)(HOST=ollenhauer)(USER=www-adm)))
 * (ADDRESS=(PROTOCOL=tcp)(HOST=172.22.250.27)(PORT=53048)) sh * * * 0 

...................................... 
The following versions are used: 
apache 2.0.39 
mod_perl: 1.99_04 
DBI: 1.30 
DBD-Oracle: 1.12 


................. 
#sample script: 
#!/usr/local/bin/perl -w 

BEGIN { 
    $ENV{ORACLE_HOME} = '/opt/oracle/app/product/8.1.6'; 
    $ENV{ORACLE_SID}  = 'SPD'; 
} 

use CGI; 

use DBI;   

  
my $db_name = 'dbi:Oracle:sun1';  
my $db_user = 'webuser'; 
my $db_pass = 'topsecret'; 

my $q=CGI->new; 

my $dbh = DBI->connect($db_name, $db_user, $db_pass, 
   {LongReadLen => 65534, 
    RaiseError  => 1, 
    AutoCommit  => 0}); 

my $query = q{ 
SELECT count (*) 
FROM asdb_mgr.stammdaten14 
        WHERE bis is null  }; 

my $sth = $dbh->prepare($query); 

my $rc  = $sth->execute(); 

my $count = $sth->fetchrow_array; 

print $q->header; 
print "Anzahl der SPD-MdBs: $count\n"; 

$sth->finish; 

$dbh->disconnect; 

............................... 
httpd.conf: 

Alias /perl  /server/apache-dev/perl 
<IfModule mod_perl.c> 

  PerlRequire "/server/apache-dev/conf/perl-startup.pl" 

    <Location /perl> 
       SetHandler       perl-script 
       PerlResponseHandler ModPerl::Registry 
       PerlOptions +ParseHeaders 
       Options          +ExecCGI 
    </Location> 

</IfModule> 

...................................... 
perl-startup.sh: 

#  file:perl-startup.pl 
#  --------------- 
  use Apache2 (); 
  use Apache::compat (); 
  
  use lib qw(/server/apache-dev/perl/); 
  
  
  use ModPerl::Util ();   
  use Apache::RequestRec (); 
  use Apache::RequestIO (); 
  use Apache::RequestUtil (); 
  
  use Apache::Server (); 
  use Apache::ServerUtil (); 
  use Apache::Connection (); 
  use Apache::Log (); 
  
  use APR::Table (); 
  
  use ModPerl::Registry (); 
  
  use Apache::Const -compile => ':common'; 
  use APR::Const -compile => ':common'; 
  
  1; 

.......................................... 


Thanks, 

Fredo 

-- 
Dr. Fredo Sartori                        Tel. 030-227-55061
SPD-Fraktion im Deutschen Bundestag      FAX  030-227-56169
Platz der Republik                       e-mail: [EMAIL PROTECTED]
11011 Berlin

Reply via email to