I've done my searching online, throughout several groups, and now I turn to
you guys.

 

I've been having trouble figuring out how to detect, from within my
ColdFusion application, whether or not my database connection is valid. 

 

The DB setup is valid, but my goal is to automatically detect when the
database server is temporarily down/unavailable in order to display an
automatic "maintenance" message in the case of a crash or true maintenance
when the database is offline.

 

I've tried to put a simple query into my Application file and use CFQUERY's
Timeout to force a quick (5 second) error within a CFTRY, but I'm inclined
to think that it only has an affect on SQL Server when it's up and running,
but taking too long to return a result. With my current attempt, it's taking
up to 18 seconds to fail, which is just too long. Even using CFSETTING to
set RequestTimeout to a lower value doesn't seem to have an affect.

 

This was my attempt:

 

      <CFTRY>

            <CFQUERY datasource="#DBDATASOURCE#" username="#DBUSERNAME#"
password="#DBPASSWORD#" name="testConnection" timeout="5">

                  SELECT TOP 1 THEME_ID FROM TBL_THEME

            </CFQUERY>

      <CFCATCH>

            <!-- DB Connection failed -->

            <cfinclude template="Maint.cfm">

            <CFABORT>

      </CFCATCH>

      </CFTRY>        

 

If it matters, we're using MSSQL now, though we're planning to switch to
MySQL eventually. I know there are timeout differences with CFQUERY's
Timeout in conjunction with different DB drivers and I'd like to come up
with a single, generic solution.

 

I appreciate any feedback.

 

Rob



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:275850
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to