Ask a Question related to PERL Modules, Design and Development.
-
zanzib63 #1
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
-
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... -
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... -
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... -
#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... -
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... -
Sherm Pendley #2
Re: Apache::DBI help
"zanzib63" <provencb@iro.umontreal.ca> writes:
Note the PIDs in the first column - that's not a single Apache child process> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 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'
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
re-connecting, it's each child establishing its own connection.
Of course not. CGI is not a persistent environment. The script runs, prints> But when i try to make transaction or temporary table with CGI script,
> the connection aren't persistent.
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
-
zanzib63 #3
Re: Apache::DBI help
> Of course not. CGI is not a persistent environment. The script runs, prints
Sorry if this is a stupid question but how can I use persistent> output, then exits.
connection ? Our intranet application run on apache/perl/cgi. There
must be a way to keep persistent connection beetween 2 script call?
zanzib63 Guest
-
Sherm Pendley #4
Re: Apache::DBI help
"zanzib63" <provencb@iro.umontreal.ca> writes:
One way is to use Apache::DBI under mod_perl. That keeps your compiled script>>> 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?
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
-
Sherm Pendley #5
Re: Apache::DBI help
Sherm Pendley <sherm@Sherm-Pendleys-Computer.local> writes:
To elaborate a bit - you want to run your application as a mod_perl handler,> "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.
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
-
zanzib63 #6
Re: Apache::DBI help
Thanks for all the info. I really appreciate your help
zanzib63 Guest



Reply With Quote

