Highlighted

CF11-setup error page for database not available

New Here ,
Nov 14, 2019

Copy link to clipboard

Copied

we are using ColdFusion 11 enterprise , every evening our database backup team taking database offline for baclup, unfortunatly some user are trying to access same database, we wanted to setup error page on that datasource availability, need help 

TOPICS
Advanced techniques, Database access, Server administration

Views

241

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

CF11-setup error page for database not available

New Here ,
Nov 14, 2019

Copy link to clipboard

Copied

we are using ColdFusion 11 enterprise , every evening our database backup team taking database offline for baclup, unfortunatly some user are trying to access same database, we wanted to setup error page on that datasource availability, need help 

TOPICS
Advanced techniques, Database access, Server administration

Views

242

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 14, 2019 0
BKBK LATEST
Adobe Community Professional ,
Nov 16, 2019

Copy link to clipboard

Copied

A possible solution:

1) Make sure your Application.cfc file implements the onError eventhandler.

2) Include code in the onError handler to check whether datasources are available. For example, to check whether a datasource, myDSN, is available, you could do something like 

<cffunction name="onError">
<cfargument name="Exception" required=true >
<cfargument name = "EventName" type="String" required=true >

	<!--- Login into Coldfusion Administrator. --->
	<cfset  createObject("component","cfide.adminapi.administrator").login("my_CFAdmin_password")>
	
	<!--- Instantiate the data source object. --->
	<cfset  var datasourceObject = createObject("component","cfide.adminapi.datasource")>
	 
	<!--- Get a structure containing all the data sources --->
	<cfset var datasources = datasourceObject.getDatasources()>
	 
	<cfif structCount(datasources) eq 0 or not structKeyExists(datasources, 'myDSN')>
		Sorry, the data source in unavailable.
	</cfif>

</cffunction>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 16, 2019 0