You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Pramod Sokke <pr...@investools.com> on 2000/08/16 20:00:28 UTC

DB persistence

Hi all,

I think I misled everybody with my previous question on this topic. To put
it in simple words:
Apache 1.3.12/mod_perl 1.24/Solaris 2.7
I'm establishing db connection at server startup and the logs indicate
that's done. But in my subsequent calls to 'connect' in my scripts, I see
the same message "Establishing connection to PURCHASEDB:purchasedb" in my
webserver error log. Does this mean it's ignoring the already available db
handle and making fresh connections?
In other words, how do I make sure whether the original handle is used or
if a fresh connection is established?
Any help is greatly appreciated.

Thanks,
Pramod

RE: DB persistence

Posted by Michael Peppler <mp...@peppler.org>.
Pramod Sokke writes:
 > >There's an Apache::Sybase::DBlib module floating around somewhere that 
 > >you could use if you don't want to make all those changes.
 > 
 > I'm right now using that module and it's with that module that I'm getting
 > the message in my error logs about establishing connection to db for every
 > connect call. That's what has left me totally confused whether it's
 > actually using the established connection or not.

You're going to get a fresh connection for each apache child process
when that process' connect() call is called. On subsequent calls you
should not get this.

You could verify this by adding:

sub connect {
    my($self, @args) = @_;
        my($Uid, $Pwd, $Srv) = @args;
    my $idx = join ":", (@args) || (@{$self});
    return $Connected{$idx} if $Connected{$idx};
    print STDERR "($$) connecting to $idx...\n" if $main::DEBUG;
#---------------^^^^^^^
    $Connected{$idx} = Sybase::DBlib->dblogin($Uid, $Pwd, $Srv);
}

which will include the process id of the process connecting.

 > 
 > >However, in general it's a lot better if you can avoid having API
 > >calls all over the place.
 > >For example in the app I'm currently writing there is only 1
 > >subroutine that calls the database API (Sybase::CTlib, in this case).
 > >
 > >This adds a bit of overhead in the perl code, but cuts *way* down on
 > >the code maintenance!
 > 
 > I totally agree with you on this, but I'm helpless here because I have to
 > work with already existing code that has API calls all over the place.

I understand that - just a general comment.

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com

RE: DB persistence

Posted by Pramod Sokke <pr...@investools.com>.
>There's an Apache::Sybase::DBlib module floating around somewhere that 
>you could use if you don't want to make all those changes.

I'm right now using that module and it's with that module that I'm getting
the message in my error logs about establishing connection to db for every
connect call. That's what has left me totally confused whether it's
actually using the established connection or not.

>However, in general it's a lot better if you can avoid having API
>calls all over the place.
>For example in the app I'm currently writing there is only 1
>subroutine that calls the database API (Sybase::CTlib, in this case).
>
>This adds a bit of overhead in the perl code, but cuts *way* down on
>the code maintenance!

I totally agree with you on this, but I'm helpless here because I have to
work with already existing code that has API calls all over the place.


-Pramod


> > At 02:21 PM 8/16/00 -0400, Shimon Rura wrote:
> > >It seems to be starting a new connection each time.  If you want
connection
> > >pooling, you should use the Apache::DBI module, which will transparently
> > >pool DBI connections for you.
> > >
> > >Shimon Rura
> > >
> > >> Hi all,
> > >>
> > >> I think I misled everybody with my previous question on this topic.
To put
> > >> it in simple words:
> > >> Apache 1.3.12/mod_perl 1.24/Solaris 2.7
> > >> I'm establishing db connection at server startup and the logs indicate
> > >> that's done. But in my subsequent calls to 'connect' in my scripts,
I see
> > >> the same message "Establishing connection to PURCHASEDB:purchasedb"
in my
> > >> webserver error log. Does this mean it's ignoring the already
available db
> > >> handle and making fresh connections?
> > >> In other words, how do I make sure whether the original handle is
used or
> > >> if a fresh connection is established?
> > >> Any help is greatly appreciated.
> > >>
> > >> Thanks,
> > >> Pramod
> > 
>
>-- 
>Michael Peppler         -||-  Data Migrations Inc.
>mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
>Int. Sybase User Group  -||-  http://www.isug.com
>Sybase on Linux mailing list: ase-linux-list@isug.com
> 

RE: DB persistence

Posted by Michael Peppler <mp...@peppler.org>.
Pramod Sokke writes:
 > Hmmm, the reason I'm not using Apache::DBI right now is coz our current
 > scripts are using DBlib to talk to Sybase. Looks like I have to make
 > thousands of changes all over the place after all and start using DBI.
 > Those of you folks already using Apache::DBI, can you tell me what kind of
 > message is logged in webserver error logs everytime a call to 'connect' is
 > made?

There's an Apache::Sybase::DBlib module floating around somewhere that 
you could use if you don't want to make all those changes.

However, in general it's a lot better if you can avoid having API
calls all over the place.

For example in the app I'm currently writing there is only 1
subroutine that calls the database API (Sybase::CTlib, in this case).

This adds a bit of overhead in the perl code, but cuts *way* down on
the code maintenance!

Michael


 > At 02:21 PM 8/16/00 -0400, Shimon Rura wrote:
 > >It seems to be starting a new connection each time.  If you want connection
 > >pooling, you should use the Apache::DBI module, which will transparently
 > >pool DBI connections for you.
 > >
 > >Shimon Rura
 > >
 > >> Hi all,
 > >>
 > >> I think I misled everybody with my previous question on this topic. To put
 > >> it in simple words:
 > >> Apache 1.3.12/mod_perl 1.24/Solaris 2.7
 > >> I'm establishing db connection at server startup and the logs indicate
 > >> that's done. But in my subsequent calls to 'connect' in my scripts, I see
 > >> the same message "Establishing connection to PURCHASEDB:purchasedb" in my
 > >> webserver error log. Does this mean it's ignoring the already available db
 > >> handle and making fresh connections?
 > >> In other words, how do I make sure whether the original handle is used or
 > >> if a fresh connection is established?
 > >> Any help is greatly appreciated.
 > >>
 > >> Thanks,
 > >> Pramod
 > 

-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com

RE: DB persistence

Posted by Pramod Sokke <pr...@investools.com>.
Hmmm, the reason I'm not using Apache::DBI right now is coz our current
scripts are using DBlib to talk to Sybase. Looks like I have to make
thousands of changes all over the place after all and start using DBI.
Those of you folks already using Apache::DBI, can you tell me what kind of
message is logged in webserver error logs everytime a call to 'connect' is
made?

Thanks,
Pramod

At 02:21 PM 8/16/00 -0400, Shimon Rura wrote:
>It seems to be starting a new connection each time.  If you want connection
>pooling, you should use the Apache::DBI module, which will transparently
>pool DBI connections for you.
>
>Shimon Rura
>
>> Hi all,
>>
>> I think I misled everybody with my previous question on this topic. To put
>> it in simple words:
>> Apache 1.3.12/mod_perl 1.24/Solaris 2.7
>> I'm establishing db connection at server startup and the logs indicate
>> that's done. But in my subsequent calls to 'connect' in my scripts, I see
>> the same message "Establishing connection to PURCHASEDB:purchasedb" in my
>> webserver error log. Does this mean it's ignoring the already available db
>> handle and making fresh connections?
>> In other words, how do I make sure whether the original handle is used or
>> if a fresh connection is established?
>> Any help is greatly appreciated.
>>
>> Thanks,
>> Pramod


RE: DB persistence

Posted by Mark D Wolinski <ma...@mrmark.com>.
If I have mod_perl installed, will CGI's not running under mod_perl benefit
from Apache::DBI as well if they connect to the same database?

Mark W


> -----Original Message-----
> From: Shimon Rura [mailto:srura@carsinfo.com]
> Sent: Wednesday, August 16, 2000 2:22 PM
> To: Pramod Sokke; modperl@apache.org
> Subject: RE: DB persistence
>
>
> It seems to be starting a new connection each time.  If you want
> connection
> pooling, you should use the Apache::DBI module, which will transparently
> pool DBI connections for you.
>
> Shimon Rura
>
> > -----Original Message-----
> > From: Pramod Sokke [mailto:pramod@investools.com]
> > Sent: Wednesday, August 16, 2000 2:00 PM
> > To: modperl@apache.org
> > Subject: DB persistence
> >
> >
> > Hi all,
> >
> > I think I misled everybody with my previous question on this
> topic. To put
> > it in simple words:
> > Apache 1.3.12/mod_perl 1.24/Solaris 2.7
> > I'm establishing db connection at server startup and the logs indicate
> > that's done. But in my subsequent calls to 'connect' in my
> scripts, I see
> > the same message "Establishing connection to
> PURCHASEDB:purchasedb" in my
> > webserver error log. Does this mean it's ignoring the already
> available db
> > handle and making fresh connections?
> > In other words, how do I make sure whether the original handle
> is used or
> > if a fresh connection is established?
> > Any help is greatly appreciated.
> >
> > Thanks,
> > Pramod
> >
>


RE: DB persistence

Posted by Shimon Rura <sr...@carsinfo.com>.
It seems to be starting a new connection each time.  If you want connection
pooling, you should use the Apache::DBI module, which will transparently
pool DBI connections for you.

Shimon Rura

> -----Original Message-----
> From: Pramod Sokke [mailto:pramod@investools.com]
> Sent: Wednesday, August 16, 2000 2:00 PM
> To: modperl@apache.org
> Subject: DB persistence
>
>
> Hi all,
>
> I think I misled everybody with my previous question on this topic. To put
> it in simple words:
> Apache 1.3.12/mod_perl 1.24/Solaris 2.7
> I'm establishing db connection at server startup and the logs indicate
> that's done. But in my subsequent calls to 'connect' in my scripts, I see
> the same message "Establishing connection to PURCHASEDB:purchasedb" in my
> webserver error log. Does this mean it's ignoring the already available db
> handle and making fresh connections?
> In other words, how do I make sure whether the original handle is used or
> if a fresh connection is established?
> Any help is greatly appreciated.
>
> Thanks,
> Pramod
>