Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Check Data Base is Up or Down

New Here ,
Jul 28, 2009 Jul 28, 2009

Hi All,

              How can i check whether the Data Base is Up or Down in cold fusion.Bacause in Cold fusion Data base connectional are made in Connection pool as  in Data source in Admin part, But some time my Data base goes  down.In that time the Data source is correct .And the my .cfm file try to  access the DB but DB is not responsing.  So bacause of this my Application goes slow .Please help me how can i check the DB is up or down in Cold fusion coding.

Thanks & My Best regrads
Karthikeyan.J

TOPICS
Database access
806
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 28, 2009 Jul 28, 2009

As far as I know you can't

You can check to see if the database is responding by trying a query

<cftry>

     <cfquery name="something" datasource="mydsn">

          select something trivial from something else trivial

     </cfquery>

     <cfcatch type="database">DB is not responding</cfcatch>

</cftry>

otherwise to see if the DB is "up" or "down" you need server access, cause it could always be up but not ersponding...

-sean

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 31, 2009 Jul 31, 2009
LATEST

Sure... here's a good way to do it.

  1. Wrap your code, first, in a <cftry>/<cfcatch> block.  This will arrange to neatly "catch" any unexpected condition ... like a database server that has gone down, causing your queries to time-out.
  2. Within that, use a <cftransaction> block to make all of your updates (if any) atomic.  ColdFusion will neatly take care of committing the transaction if the end of the block is reached normally, and of rolling-back the transaction on failure.
  3. Now, use the timeout= parameter on your <cfquery> and other statements, as appropriate for each one of them.  If a timeout occurs, an exception will be thrown and this will be taken care of by the two tags mentioned previously.  If some other type of failure is detected directly, such as "failure to connect with database server," it also will throw an exception (albeit of a different type) in the same way.

What's nice about this strategy is that, not only is it very rugged and reliable, but it is also very efficient.  "99.9% of the time, a timeout does not happen," but when and if it does, you can very-reliably handle it ... as the "exception to the rule" that it properly is.  You should apply this strategy in all of your code.

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