List:General Discussion« Previous MessageNext Message »
From:Jack Barnett Date:October 12 2000 2:22pm
Subject:Re: Cgi perl program and connections/disconnects to the mySQL DB
View as plain text  
----- Original Message -----
From: "Don Read" <dread@stripped>
To: "Jack Barnett" <jbarnett@stripped>
Cc: <mysql@stripped>
Sent: Wednesday, October 11, 2000 6:47 PM
Subject: RE: Cgi perl program and connections/disconnects to the mySQL DB


>
> On 11-Oct-00 Jack Barnett wrote:
> >
> > Hi,
> >
> > I am not sure if this is the right place to ask, but I will give it a
shot.
> >
> > I wrote a decent size perl cgi application awhile back with staight
ASCII
> > files, for performance and scaliablity reasons I have decided to try
using
> > mySQL as a back end to store the data.
> >
> > The perl cgi program is in 2 parts, one is a "backend" (in-house) module
> > that does the "meat" of the program and the other part is the front end
> > "interface" that makes it glitterly.
> >
> > What I was trying to do is connect to the DB in the backend module when
it
> > is loaded (in the "new" funcation), but the problem is, when it returns
it
> > kills the DB connection, I have also tried to connection using a sub
routine
> > or method (whatever you real programmers call it :) and when it returns,
it
> > kills the connection to the database.
> >
>
> Sounds like the DB handle is created on the stack, when the "new"
sub-routine
> returns, the handle goes out of scope ( & closes the connection).
>
> If so, one solution would be to make the handle a global variable, open
the
> connect once at the start of the process and close at the end (or just
exit, as
> you've discovered: the connection takes care of it's own destructor).

That was it, declared em globally and everything works find now.

Thanks,
Jack


> <snip>
>
> >
> > I am not sure the best way to go about this.  The only way I can think
of is
> > if I fork a child proc off and have that child proc maintain a
connection to
> > the DB till the parent dies, but don't know if that is the best
solution.
>
>
> >
> > Also "resource wise", would it be better to maintain 1 connection to the
db
> > for the life of the program, or to only connectin/disconnect when db
access
> > was needed (this might be 10-20 times for the life of the program).
> >
>
> Yes.
> >
> > Jack
> >
> >
> >
> >
> > --
> > ---------------------------------------------------------------------
> > Please check "http://www.mysql.com/documentation/manual.php" before
> > posting. To request this thread, e-mail
mysql-thread52992@stripped
> >
> > To unsubscribe, send a message to:
> >     <mysql-unsubscribe-dread=texas.net@stripped>
> >
> > If you have a broken mail client that cannot send a message to
> > the above address (Microsoft Outlook), you can use:
> >     http://lists.mysql.com/php/unsubscribe.php
>
> --
> Don Read                                         dread@stripped
> --- The problem with people who have no vices is that you can be
>         sure they're going to have some pretty annoying virtues.
>
> --
> ---------------------------------------------------------------------
> Please check "http://www.mysql.com/documentation/manual.php" before
> posting. To request this thread, e-mail mysql-thread53017@stripped
>
> To unsubscribe, send a message to:
>     <mysql-unsubscribe-jbarnett=axil.netmate.com@stripped>
>
> If you have a broken mail client that cannot send a message to
> the above address (Microsoft Outlook), you can use:
>     http://lists.mysql.com/php/unsubscribe.php
>
>

Thread
Cgi perl program and connections/disconnects to the mySQL DB?Jack Barnett11 Oct
  • Re: Cgi perl program and connections/disconnects to the mySQL DB?Bill Hess11 Oct
  • RE: Cgi perl program and connections/disconnects to the mySQL DBDon Read12 Oct
    • Re: Cgi perl program and connections/disconnects to the mySQL DBJack Barnett12 Oct
  • Re: Cgi perl program and connections/disconnects to the mySQL DB?Jack Barnett12 Oct
Re: Cgi perl program and connections/disconnects to the mySQL DB?Jack Barnett11 Oct