Vote +1
Scott if you want to know if your database is down and then turn it off as a
service you can do this via an inner TimerTask. I implement somthing along
the lines of if the database is down, set its status as down with my service
manager.
Then you can write code to check the service manager before displaying
database functionality if you really want to.
----Original Message Follows----
From: Dakota Jack <[EMAIL PROTECTED]>
Reply-To: Dakota Jack <[EMAIL PROTECTED]>
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: Seeking Advice Error Handling
Date: Wed, 1 Jun 2005 07:33:31 -0700
Hi, Scott,
Wherever you access the database and encounter the error is where the
error should be handled. A rule-of-thumb I employ is to handle all
errors as soon as possible and as near to the actual error as
possible. I think that testing to see if your database is working is
not a good idea. You have to assume that your database is working and
then handle what to do if it is not.
Depending on some subclass of RequestProcessor really weds your code
to Struts in a way that is not good in my opinion. If you handle the
error where it happens, then that should cover you completely. Your
response to an error should be, I think, with a different
ActionForward and not with a different (chained) Action. Thus, the
sequence would be: (1) use Action, (2) hand off to business logic, (3)
access to database, (4) FAILURE and consequent handling of error back
to the Action which then uses a (5) "failure" ActionForward with an
ActionMessage or ActionError delineating what happened to the client.
On 6/1/05, Scott Purcell <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have created a site with a mysql database back-end, and full struts
front end. I have a filter to ensure the creation of some session app
objects, and the site is pretty clean.
>
> But over the weekend, I found a problem that I am seeking advice from.
For some reason, the mysql database went down, causing the site to be all
screwed up. I have extended the RequestProcessor but can not figure out how
to handle errors from the database.
>
> I would like to in the requestProcessor extended class, possibly do a
simple query against a known table, and if the result is null, switch them
to a site down action class.
>
> Can this be done in the requestProcessor area?
>
> Any advice would be appreciated.
>
> Scott
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]