I was able to get the following code to run sucessfully. I took the database
offline so CF couldn't connect to it. As a second test, I also changed the
server name to an invalid on in the datasource setup, and both scenarios worked.
cftry
cfquery name=testme datasource=datasource maxrows=10 timeout=2
Select * from testdb
/cfquery
cfcatch
cfquery name=testme datasource=datasource2 maxrows=10 timeout=5
Select * from testdb
/cfquery
/cfcatch
/cftry
Hi a bit stuck at the moment,
I am trying to implement a DB fail over to a slave database through CF
9. I am using MYSQL as a DB. I have setup datasource in the
application.cfc to point to the main db. When i trigger a stop
service on the main db - which causes a failed db connection, i'm
trying to get CF to change the datasource to the failover database.
All that happens is the site keeps trying to connect to the main db
without updating the db datasource in the cfcatch. Note: this code
below works if i have a syntax error in the query, but not for a DB
connection failure.
See my code below, which i am putting in the onRequestStart and i have
unchecked Maintain Connections in the datasource settings.
cftry
!--- Test whether the DB this application uses is accessible
by getting some data. ---
cfquery name=testDB dataSource=#application.primary_datasource#
maxrows=2
SELECT id FROM user
/cfquery
cfcatch type=database
cfset application.primary_datasource = failoverdb
/cfcatch
/cftry
I welcome any thoughts and assistance
thanks in advance.
Bas.
~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346112
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm