Hi,
I have problems to setup persistent database connection for my perl project
using mod_perl.
It tooks me two days which i still cann't figure out how mod_perl works with
Apache::DBI.
My Server Settings:
ActiveState Perl 5.8.8 build 822
Apache HTTP Server 2.2.9
Apache DBI 1.06
mod_perl 2.03
DBD-Oracle 1.17
--------------Adding to httpd.conf--------------
LoadFile "C:/Perl/bin/perl58.dll"
LoadModule perl_module modules/mod_perl.so
PerlSetEnv DBI_TRACE "3=C:/Perl/dbitrace.log"
PerlModule Apache::DBI
PerlRequire "C:/Perl/lib/startup.pl"
--------------End-------------------------------------
--------------startup.pl--------------
#!c:/perl/bin/perl.exe
$ENV{MOD_PERL} or die "GATEWAY_INTERFACE not Perl!";
#use Apache::Registry;
use Apache::DBI;
use strict;
$Apache::DBI::DEBUG = 2;
Apache::DBI->connect_on_init("dbi:Oracle:host=xxx;sid=xxx",
"xxx", "xxx",
{PrintError => 1, RaiseError => 0, AutoCommit =>
1,}
);
my $timeout = 0;
Apache::DBI->setPingTimeOut("dbi:Oracle:host=xxx;sid=xxx", $timeout);
1;
--------------End-------------------------------------
--------------Apache Startup Log-------------------------------------
[Wed Jul 16 14:43:54 2008] [notice] Apache/2.2.9 (Win32) mod_perl/2.0.3
Perl/v5.8.8 configured -- resuming normal operations
[Wed Jul 16 14:43:54 2008] [notice] Server built: Jun 13 2008 04:04:59
[Wed Jul 16 14:43:54 2008] [notice] Parent: Created child process 996
[Wed Jul 16 14:43:54 2008] [notice] Child 996: Child process is running
996 Apache::DBI PerlChildInitHandler
996 Apache::DBI need ping: yes
996 Apache::DBI new connect to
'host=xxx;sid=xxxxxxxxxAutoCommit=1PrintError=1RaiseError=0Username=xxx'
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Acquired the start mutex.
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Starting 64 worker threads.
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Starting thread to listen on
port 80.
--------------End-------------------------------------
I can see it sucessful open the oracle DB connection.
However, when I run an CGI script on the IE 6, it cannot find $ENV{MOD_PERL}
and start new DBI connection.
--------foo.cgi--------------------
#!c:/perl/bin/perl.exe -d
use DBI;
use CGI qw(:standard);
my $dbh = DBI->connect("dbi:Oracle:host=xxx;sid=xxx",
"xxx", "xxx",
{PrintError => 1, RaiseError => 0, AutoCommit =>
1,}
);
--------END--------------------
Do I need to do any setting in Apache for $ENV{MOD_PERL}?
Did I do any thing wrong in above code?
Thanks and Regards
Chris Z
Start at the new Yahoo!7 for a better online experience. www.yahoo7.com.au