Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default Apache::DBI help

    Hi everyone,
    I want to have persistent database connection
    I use:
    perl v5.8.7
    Apache/2.0.55
    mod_perl-2.0.2
    Apache::DBI 1.01
    I change the DB, USER, PSW value for obvious reasons.

    Here is my Httpd.conf:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PerlModule Apache2::Status
    PerlModule Apache::DBI

    PerlRequire startup.pl
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Here is my startup.pl:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #!/usr/local/bin/perl -w

    # make sure we are in a sane environment.
    $ENV{MOD_PERL} or die "GATEWAY_INTERFACE not Perl!";

    use Apache::DBI ();

    $Apache::DBI::DEBUG = 2;
    Apache::DBI->connect_on_init(DB, USER, PSW,
    {AutoCommit => 0, RaiseError => 1, PrintError => 0});

    1;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Here is the apache2 error.log:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    4627 Apache::DBI PerlChildInitHandler
    4628 Apache::DBI PerlChildInitHandler
    [Thu Jul 06 11:03:38 2006] [notice] Apache/2.0.55 (Ubuntu)
    mod_perl/2.0.2 Perl/v5.8.7 configured -- resuming normal operations
    4627 Apache::DBI need ping: yes
    4628 Apache::DBI need ping: yes
    4627 Apache::DBI new connect to 'DB USER PSW AutoCommit=0
    PrintError=0 RaiseError=1 Username=USER'
    4628 Apache::DBI new connect to 'DB USER PSW AutoCommit=0
    PrintError=0 RaiseError=1 Username=USER'
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If i look with Perl-status ([url]http://localhost/perl-status?inc[/url]) I got:

    Apache::DBI 1.01
    mod_perl2 2.000002
    So the 2 modules are loaded.

    With mysqladmin processlist, I see the 2 persistent connections:
    +----+------+-----------+-----+---------+------+-------+------------------+
    | Id | User | Host | db | Command | Time | State | Info
    |
    +----+------+-----------+-----+---------+------+-------+------------------+
    | 5 | root | localhost | ion | Sleep | 398 | |
    |
    | 6 | root | localhost | ion | Sleep | 398 | |
    |
    | 7 | root | localhost | | Query | 0 | | show processlist
    |
    +----+------+-----------+-----+---------+------+-------+------------------+

    So everything seems to be alright.
    But when i try to make transaction or temporary table with CGI script,
    the connection aren't persistent. There is no reconnect: a connection
    is created every time even if the connection's parameters are
    identical.
    Can you help me?

    zanzib63 Guest

  2. Similar Questions and Discussions

    1. starting apache with mod_perl, error on Apache.pm
      Hi, At the moment i try to install apache_1.3.29 and mod_perl1.29. The installations procedure was successful, but then i tried to start apache...
    2. Apache::AuthenNTLM runtime errors from Apache
      Hi, We are trying to use the Apache::AuthenNTLM perl module with HP/Apache and mod_perl. We have disable mod_perl from running our cgi-perl...
    3. mod_php 4.3.2 (w/ apache 2.0.40 using apache filters) - problems loading extensions
      (cross posted from php.install in hopes of increasing my chances of finding help) I've been trying to get php working on our RH8 box using a...
    4. #13024 [Com]: Problems with PHP on Apache .. when loading php script a few times Apache crash
      ID: 13024 Comment by: javri28 at hotmail dot com Reported By: j_barrancos at hotmail dot com Status: Bogus Bug...
    5. Apache::Test, Apache::Request, libapreq, mod_perl. Installation Problem.
      Hi everyone, If anyone has any insight into my problem, it would be much appreciated. I'm trying to install Scoop (scoop.kuro5hin.org) to run on...
  3. #2

    Default Re: Apache::DBI help

    "zanzib63" <provencb@iro.umontreal.ca> writes:
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > Here is the apache2 error.log:
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > 4627 Apache::DBI PerlChildInitHandler
    > 4628 Apache::DBI PerlChildInitHandler
    > [Thu Jul 06 11:03:38 2006] [notice] Apache/2.0.55 (Ubuntu)
    > mod_perl/2.0.2 Perl/v5.8.7 configured -- resuming normal operations
    > 4627 Apache::DBI need ping: yes
    > 4628 Apache::DBI need ping: yes
    > 4627 Apache::DBI new connect to 'DB USER PSW AutoCommit=0
    > PrintError=0 RaiseError=1 Username=USER'
    > 4628 Apache::DBI new connect to 'DB USER PSW AutoCommit=0
    > PrintError=0 RaiseError=1 Username=USER'
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Note the PIDs in the first column - that's not a single Apache child process
    re-connecting, it's each child establishing its own connection.
    > But when i try to make transaction or temporary table with CGI script,
    > the connection aren't persistent.
    Of course not. CGI is not a persistent environment. The script runs, prints
    output, then exits.

    sherm--

    --
    Cocoa programming in Perl: [url]http://camelbones.sourceforge.net[/url]
    Hire me! My resume: [url]http://www.dot-app.org[/url]
    Sherm Pendley Guest

  4. #3

    Default Re: Apache::DBI help

    > Of course not. CGI is not a persistent environment. The script runs, prints
    > output, then exits.
    Sorry if this is a stupid question but how can I use persistent
    connection ? Our intranet application run on apache/perl/cgi. There
    must be a way to keep persistent connection beetween 2 script call?

    zanzib63 Guest

  5. #4

    Default Re: Apache::DBI help

    "zanzib63" <provencb@iro.umontreal.ca> writes:
    >> Of course not. CGI is not a persistent environment. The script runs, prints
    >> output, then exits.
    >
    > Sorry if this is a stupid question but how can I use persistent
    > connection?
    One way is to use Apache::DBI under mod_perl. That keeps your compiled script
    in memory instead of launching it as a separate child process for each request,
    which is what happens when it's run as a CGI.

    sherm--

    --
    Cocoa programming in Perl: [url]http://camelbones.sourceforge.net[/url]
    Hire me! My resume: [url]http://www.dot-app.org[/url]
    Sherm Pendley Guest

  6. #5

    Default Re: Apache::DBI help

    Sherm Pendley <sherm@Sherm-Pendleys-Computer.local> writes:
    > "zanzib63" <provencb@iro.umontreal.ca> writes:
    >
    >>> Of course not. CGI is not a persistent environment. The script runs, prints
    >>> output, then exits.
    >>
    >> Sorry if this is a stupid question but how can I use persistent
    >> connection?
    >
    > One way is to use Apache::DBI under mod_perl. That keeps your compiled script
    > in memory instead of launching it as a separate child process for each request,
    > which is what happens when it's run as a CGI.
    To elaborate a bit - you want to run your application as a mod_perl handler,
    or using Apache::Registry. Even though you've installed mod_perl and loaded
    Apache::DBI, scripts in /cgi-bin are still run as separate child processes,
    even those written in Perl. (That's part of the definition of a CGI, by the
    way - if it's not a separate child process, it's not a CGI.)

    Apache::Registry is a good way to migrate CGI scripts to mod_perl.

    sherm--

    --
    Cocoa programming in Perl: [url]http://camelbones.sourceforge.net[/url]
    Hire me! My resume: [url]http://www.dot-app.org[/url]
    Sherm Pendley Guest

  7. #6

    Default Re: Apache::DBI help

    Thanks for all the info. I really appreciate your help

    zanzib63 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139