You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Curtis Hawthorne <cu...@ourtownusa.net> on 2001/07/27 23:06:54 UTC

mod_perl/DBI problem

I'm writing a script that will run under mod_perl that uses DBI to connect
to an MS SQL server.  The script works fine and mod_perl speeds it up quite
a bit.  Every so often, when the script tries to connect to the SQL server,
the connection times out (I think the SQL server's a little slow), and I get
an Internal Server Error message.  My problem is that, instead of trying to
connect to the server again, the next time the script is run, the database
connection handle stays the same and I get the following error in my logs
over and over again "Can't call method "quote" on an undefined value" (the
first thing the script does is a $dbh->quote of a variable).  The code that
does the connection to the database is in a module that is used by the
script, but not in a subroutine.

So, how can I have it try to connect to the database again if it fails, but
keep the connection persistent if it doesn't?  Would there be some way to
have the script exit completely when it gets an error like that, even though
it's under mod_perl?

Thanks!

Curtis H.



Re: mod_perl/DBI problem

Posted by Curtis Hawthorne <cu...@ourtownusa.net>.
Even when using Apache::DBI, I still have the same problem - If it times out
once, it won't try again.  I set Apache::DBI::DEBUG = 2, and here's the log:

When I first load the page and get the timeout:

197345 Apache::DBI             need ping: yes
197345 Apache::DBI             new connect to
'DatabaseusernamepasswordPrintError=1RaiseError=1AutoCommit=1'
[Tue Jul 31 09:31:45 2001] [error] DBI->connect(Database) failed:
[Microsoft][ODBC SQL Server Driver]Timeout expired (SQL-S1T00)(DBD:
db_login/SQLConnect err=-1) at DatabaseStuff.pm line 32
Compilation failed in require at (eval 8) line 9.
BEGIN failed--compilation aborted at (eval 8) line 9.

Try to reload the page:
[Tue Jul 31 09:33:11 2001] [error] Can't call method "quote" on an undefined
value at DatabaseStuff.pm line 660.

Try again:
[Tue Jul 31 09:33:14 2001] [error] Can't call method "quote" on an undefined
value at DatabaseStuff.pm line 660.

And so on.  The only thing that seems to fix it is restarting the server,
which by the way is Apache/1.3.20 (Win32) with mod_perl/1.26_01-dev.
Apache::DBI is version 0.87, DBD::ODBC (which I use for my database
connections) is version 0.28.

Any ideas?

Curtis H.

----- Original Message -----
From: "Ged Haywood" <ge...@www2.jubileegroup.co.uk>
To: "Curtis Hawthorne" <cu...@ourtownusa.net>
Cc: <mo...@apache.org>
Sent: Friday, July 27, 2001 4:19 PM
Subject: Re: mod_perl/DBI problem


> Hi there,
>
> On Fri, 27 Jul 2001, Curtis Hawthorne wrote:
>
> > So, how can I have it try to connect to the database again if it fails,
but
> > keep the connection persistent if it doesn't?
>
> Have a look in the Guide, there's lots of stuff in there about
> Apache::DBI.  http://perl.apache.org/guide.
>
> 73,
> Ged.
>
>



Re: mod_perl/DBI problem

Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,

On Fri, 27 Jul 2001, Curtis Hawthorne wrote:

> So, how can I have it try to connect to the database again if it fails, but
> keep the connection persistent if it doesn't?

Have a look in the Guide, there's lots of stuff in there about
Apache::DBI.  http://perl.apache.org/guide.

73,
Ged.