Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:22:43+00:00 2026-05-29T20:22:43+00:00

I have a ColdFusion cfm file that communicates with a sql server database. Right

  • 0

I have a ColdFusion cfm file that communicates with a sql server database. Right now if something goes wrong with the database connection, it brings up an error page generated by ColdFusion. Is there a way I can catch the errors and display a message like, “Database server temporarily down, please come back later”?
Ted

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:22:46+00:00Added an answer on May 29, 2026 at 8:22 pm

    You can use try/catch for an individual query – this will be the most granular approach.

    <cftry>
    
      <cfquery datasource="myDSN">BROKEN SQL</cfquery>
    
      <cfcatch type="database">
        <h1>Database Offline!</h1>
        <p>Sorry, the database threw an error: #cfcatch.queryError#.  Try again later.</p><cfabort>
      </cfcatch>
    
    </cftry>
    

    You can also use the cferror tag for global exception handling (put this in Application.cfm):

    <cferror 
      type="exception" 
      exception="database" 
      template="myFriendlyDatabaseErrorTemplate.cfm">
    

    You can also use onError method within Application.cfc, which will also (like the cferror tag) catch all errors that occur during the request:

    <cffunction name="onError" returnType="void">
        <cfargument name="Exception" required=true/>
        <cfargument name="EventName" type="String" required=true/>
        <cfif arguments.Exception IS "database">
          <cfinclude template="myFriendlyDatabaseErrorTemplate.cfm">
        </cfif>
    </cffunction>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a complex sql server 2008/coldfusion search page, that searches thru a
I have a line of coldfusion code that includes an cfm file encoded with
I am using ColdFusion 9.0.1. I have a new web site that uses Bikes.cfm
I have a form in ColdFusion that initially has 5 input fields for file
We have a ColdFusion 9 script that runs regularly reading a CSV file and
In ColdFusion version 9, I have the following in Index.cfm: <cfdump var=#Application#> But the
I have a ColdFusion script that does: <cfset content = replace(content,&##147;,,all)> Which replaces &147;
I have started design of a ColdFusion application that is entirely web based. Not
I have been tasked with going through a number of ColdFusion sites that have
I'm new to coldfusion. I have page called test1.cfm <form action = test2.cfm method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.