persistent database connection - Apache::DBI with mod_perl - modperl

This is a discussion on persistent database connection - Apache::DBI with mod_perl - modperl ; Hi, * I have problems to setup persistent database connection for my perl projectusing mod_perl. * It tooks me two days which i still cann't figure out how mod_perl works with Apache: BI. * My Server Settings: ActiveState Perl 5.8.8 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: persistent database connection - Apache::DBI with mod_perl

  1. persistent database connection - Apache::DBI with mod_perl

    Hi,
    *
    I have problems to setup persistent database connection for my perl projectusing mod_perl.
    *
    It tooks me two days which i still cann't figure out how mod_perl works with Apache:BI.
    *
    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:BI
    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:BI;
    use strict;

    $Apache:BI:EBUG = 2;

    Apache:BI->connect_on_init("dbi:Oracle:host=xxx;sid=xxx",
    ************************* *** "xxx", "xxx",
    ************************* *** {PrintError => 1, RaiseError => 0, AutoCommit => 1,}
    ************************* *** );
    *
    my $timeout = 0;
    Apache:BI->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:BI************ PerlChildInitHandler
    996 Apache:BI************ need ping: yes
    996 Apache:BI************ 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 onport 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

  2. Re: persistent database connection - Apache::DBI with mod_perl

    Quoting Chris Zhuang :

    > Hi,
    > 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--------------------
    >


    It looks like your CGI's are are running under CGI, not
    ModPerl::PerlRun, or ModPerl::Registry.

    see:
    http://perl.apache.org/docs/2.0/user...gistry_Scripts


  3. Re: persistent database connection - Apache::DBI with mod_perl

    Hi adam,
    *
    I got that mod_perl works on my server.
    *
    But how to setup Komodo 3.1 to debug mod_perl?
    *
    It seems like Komodo can only debug mod_cgi.
    *
    My httpd.conf setting:
    *

    * use lib qw("C:/Program Files/ActiveState Komodo 3.1/dbgp/perllib");
    * $ENV{PERLDB_OPTS} = "RemotePort=127.0.0.1:1417 LogFile=stderr";
    * use Apache:B ();
    * Apache:B->init;

    *
    Alias /perl/ "C:/Apache2.2/htdocs/perl/"

    * SetHandler perl-script
    * PerlHandler ModPerl::Registry
    * Options +ExecCGI
    * PerlOptions +ParseHeaders
    * PerlFixupHandler Apache:B
    * Order allow,deny
    * Allow from all


    Below is Apache error logs:
    *
    Thu Jul 17 12:50:21 2008] [error] Unable to get Terminal Size. The Win32 GetConsoleScreenBufferInfo call didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. at C:/Perl/lib/Term/ReadKey.pm line 362.\nCompilation failed in require at C:/Perl/lib/Term/ReadLine/Perl.pm line 64.\n at C:/Perl/lib/Term/ReadLine/Perl.pm line 64\n\teval {...} called at C:/Perl/lib/Term/ReadLine/Perl.pm line 64\n\tTerm::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'IO::Socket::INET=GLOB(0xa4f9cbc)', 'IO::Socket::INET=GLOB(0xa4f9cbc)') called at C:/Perl/site/lib/Apache/perl5db.pl line 2226\n\tDB::setterm called at C:/Perl/site/lib/Apache/perl5db.pl line 773\n\tDB:B called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\tModPerl::ROOT::ModPerl::Registry::C_3a_Apache 2_2e2_htdocs_perl_foo2_2ecgi::BEGIN() called at C:/Perl/lib/Term/ReadLine/readline.pm line 2\n\teval {...} called at C:/Perl/lib/Term/ReadLine/readline.pm line
    2\n\teval 'package ModPerl::ROOT::ModPerl::Registry::C_3a_Apache2_2e2 _htdocs_perl_foo2_2ecgi;sub handler {local $0 = \\'C:/Apache2.2/htdocs/perl/foo2.cgi\\';\n#line 1 C:/Apache2.2/htdocs/perl/foo2.cgi\n#!c:/perl/bin/perl.exe\r\n* use strict;\r\n* print "Content-type: text/html\\\\n\\\\n";\r\n* print "

    Environment variables

      ";\r\n* foreach (sort keys %ENV) {\r\n*** my $val = $ENV{$_};\r\n*** $val =~ s|\\\\n|\\\\\\\\n|g;\r\n*** $val =~ s|"|\\\\\\\\"|g;\r\n*** print "
    • $_ = \\\\"${val}\\\\"
    • \\\\n";\r\n* }\r\n* #sleep(10);\r\n* print "
    ";\n}\n;' called at C:/Perl/site/lib/ModPerl/RegistryCooker..pm line 677\n\tModPerl::RegistryCooker::compile('ModPerl:: Registry=HASH(0x280c1ac)', 'SCALAR(0x1c615f0)') called at C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 406\n\tModPerl::RegistryCooker::convert_script_to_ compiled_handler('ModPerl::Registry=HASH(0x280c1ac )') called at
    C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 163\n\tModPerl::RegistryCooker::default_handler('M odPerl::Registry=HASH(0x280c1ac)') called at C:/Perl/site/lib/ModPerl/Registry.pm line 31\n\tModPerl::Registry::handler('ModPerl::Registr y', 'Apache2::RequestRec=SCALAR(0x280c284)') called at C:/Perl/lib/Term/ReadLine/readline.pm line 2\n\teval {...} called at C:/Perl/lib/Term/ReadLine/readline.pm line 2\n at C:/Perl/lib/Term/ReadLine/Perl.pm line 64\n\tTerm::ReadLine::Perl::new('Term::ReadLine', 'perldb', 'IO::Socket::INET=GLOB(0xa4f9cbc)', 'IO::Socket::INET=GLOB(0xa4f9cbc)') called at C:/Perl/site/lib/Apache/perl5db.pl line 2226\n\tDB::setterm called at C:/Perl/site/lib/Apache/perl5db.pl line 773\n\tDB:B called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\tModPerl::ROOT::ModPerl::Registry::C_3a_Apache 2_2e2_htdocs_perl_foo2_2ecgi::BEGIN() called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\teval {...} called at C:/Apache2.2/htdocs/perl/foo2.cgi line
    2\n\teval 'package ModPerl::ROOT::ModPerl::Registry::C_3a_Apache2_2e2 _htdocs_perl_foo2_2ecgi;sub handler {local $0 = \\'C:/Apache2.2/htdocs/perl/foo2.cgi\\';\n#line 1 C:/Apache2.2/htdocs/perl/foo2.cgi\n#!c:/perl/bin/perl.exe\r\n* use strict;\r\n* print "Content-type: text/html\\\\n\\\\n";\r\n* print "

    Environment variables

      ";\r\n* foreach (sort keys %ENV) {\r\n*** my $val = $ENV{$_};\r\n*** $val =~ s|\\\\n|\\\\\\\\n|g;\r\n*** $val =~ s|"|\\\\\\\\"|g;\r\n*** print "
    • $_ = \\\\"${val}\\\\"
    • \\\\n";\r\n* }\r\n* #sleep(10);\r\n* print "
    ";\n}\n;' called at C:/Perl/site/lib/ModPerl/RegistryCooker..pm line 677\n\tModPerl::RegistryCooker::compile('ModPerl:: Registry=HASH(0x280c1ac)', 'SCALAR(0x1c615f0)') called at C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 406\n\tModPerl::RegistryCooker::convert_script_to_ compiled_handler('ModPerl::Registry=HASH(0x280c1ac )') called at
    C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 163\n\tModPerl::RegistryCooker::default_handler('M odPerl::Registry=HASH(0x280c1ac)') called at C:/Perl/site/lib/ModPerl/Registry.pm line 31\n\tModPerl::Registry::handler('ModPerl::Registr y', 'Apache2::RequestRec=SCALAR(0x280c284)') called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\teval {...} called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\nBEGIN failed--compilation aborted at C:/Apache2.2/htdocs/perl/foo2.cgi line 2.\n at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\teval 'package ModPerl::ROOT::ModPerl::Registry::C_3a_Apache2_2e2 _htdocs_perl_foo2_2ecgi;sub handler {local $0 = \\'C:/Apache2.2/htdocs/perl/foo2.cgi\\';\n#line 1 C:/Apache2.2/htdocs/perl/foo2.cgi\n#!c:/perl/bin/perl.exe\r\n* use strict;\r\n* print "Content-type: text/html\\\\n\\\\n";\r\n* print "

    Environment variables

      ";\r\n* foreach (sort keys %ENV) {\r\n*** my $val = $ENV{$_};\r\n*** $val =~
      s|\\\\n|\\\\\\\\n|g;\r\n*** $val =~ s|"|\\\\\\\\"|g;\r\n*** print "
    • $_ = \\\\"${val}\\\\"
    • \\\\n";\r\n*}\r\n* #sleep(10);\r\n* print "
    ";\n}\n;' called at C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 677\n\tModPerl::RegistryCooker::compile('ModPerl:: Registry=HASH(0x280c1ac)', 'SCALAR(0x1c615f0)') called at C:/Perl/site/lib/ModPerl/RegistryCooker.pm line 406\n\tModPerl::RegistryCooker::convert_script_to_ compiled_handler('ModPerl::Registry=HASH(0x280c1ac )') called at C:/Perl/site/lib/ModPerl/RegistryCooker.pm line163\n\tModPerl::RegistryCooker::default_handle r('ModPerl::Registry=HASH(0x280c1ac)') called at C:/Perl/site/lib/ModPerl/Registry.pm line 31\n\tModPerl::Registry::handler('ModPerl::Registr y', 'Apache2::RequestRec=SCALAR(0x280c284)') called at C:/Apache2.2/htdocs/perl/foo2.cgi line 2\n\teval {...}
    *
    I did a lot online search as well, but still cann't find a solution.
    *
    http://osdir.com/ml/ide.komodo.gener.../msg00008.html
    *
    Regards
    *
    Chris Z

    --- On Thu, 17/7/08, adam.prime@utoronto.ca wrote:

    From: adam.prime@utoronto.ca
    Subject: Re: persistent database connection - Apache:BI with mod_perl
    To: modperl@perl.apache.org
    Received: Thursday, 17 July, 2008, 12:33 AM

    Quoting Chris Zhuang :

    > Hi,
    > 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--------------------
    >


    It looks like your CGI's are are running under CGI, not
    ModPerl::PerlRun, or ModPerl::Registry.

    see:
    http://perl.apache.org/docs/2.0/user...gistry_Scripts


    Start at the new Yahoo!7 for a better online experience. www..yahoo7.com.au

  4. Re: persistent database connection - Apache::DBI with mod_perl

    On Wed, Jul 16, 2008 at 11:04 PM, Chris Zhuang wrote:
    > But how to setup Komodo 3.1 to debug mod_perl?


    You should probably ask the Komodo support list about that.
    Apache:B seems to be working.

    - Perrin


+ Reply to Thread