perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bennett <ch...@bennettconstruction.biz>
Subject Re: Apache::DBI connect_on_init problem
Date Sat, 17 Apr 2010 20:42:51 GMT
On 04/17/10 15:09, Jiri Pavlovsky wrote:
> On 17.4.2010 22:22, Chris Bennett wrote:
>> On 04/17/10 14:27, Jiri Pavlovsky wrote:
>>> Hello,
>>>
>>> I'm trying to prestart db connection. But Apache::DBI->connect_on_init
>>> is not working. Gives no error, but db connection is not made.
>>> Setting $Apache::DBI::DEBUG = 2 indicates that ChildInitHandler runs.
>>>
>>> I tried to create my custom ChildInitHandler and start db connection
>>> from it but it also has no effect.
>>> It also seems as if the handler was silently aborted after the connect
>>> call.
>>> I inserted debugging print before and after the connect call. In the
>>> Postgres log I can see a connection made and immediately terminated.
>>>
>>>
>>> So now I'm quite helpless as what to do.
>>>
>>
>> I use Apache::DBI and connect_on_init.
>> What are your full details? Using startup.pl?
>> what values for initial connection?
>
>
>
> Hello,
>
> my start-up.pl below. I try to setup two connections.
>
> In Apache log I see several lines like:
> 13121 Apache::DBI PerlChildInitHandler
> 13121 Apache::DBI push PerlChildExitHandler
>
> No errors. But in Postgres log I can see several very short connections
> as the first user. So maybe it is connecting and then it quits?
>
> Thats all I could find out.
>
> Thanks
>
>
>
> ----------------------------------------------
>
>
>
> #!/usr/bin/perl -w
>
>
>
> use strict;
> use Apache::DBI;
>
> $Apache::DBI::DEBUG = 2;
>
> DBI->install_driver("Pg");
>
>
>
>
> Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
> "user",
> "pass",
> {
> PrintError => 1, # warn() on errors
> RaiseError => 0, # don't die on error
> AutoCommit => 1, # commit executes immediately
> pg_enable_utf8 => 1,
> }
> );
>
> Apache::DBI->connect_on_init("dbi:Pg:dbname=p69",
> "another",
> "pass",
> {
> PrintError => 1, # warn() on errors
> RaiseError => 0, # don't die on error
> AutoCommit => 1, # commit executes immediately
> pg_enable_utf8 => 1,
> }
> );
>
>

Oh, this is your error. You may only use Apache::DBI_connect_on_init for 
ONE connection, which stays up and running. Use your more important one 
(for speed) for this.

You may also have other connections, but these will reconnect-disconnect 
each time

Use the following for those:

tack in a dbi_connect_method => 'connect'  for these other ones

Mime
View raw message