Would it be ok to get a CF app to check for a valid database before proceeding to process that request?
This is because there may be instances where the database server may be down or being upgraded, hence an error comes when a db dependant request is made.
If there is no connection to the db server, the user can be safely redirected to a safe page.
Or can cfcatch work?
How can this check be done?
Thank you.
Live connections: Data source that contains direct connection to underlying data. relies on database for all queries and undergoes real-time updates. Real-time updates – As your viz is directly connected to the underlying data, this ensures data freshness.
To see the underlying data for each field in the data source, listed by table, click the View Data icon in the top of the Data pane, next to the Search field. You can open the View Data for the Data pane in Tableau Desktop only.
Live allows you real-time data while extracts are kind of batch which needs to be refreshed from time to time to get the updated data. So, in the case of live connection whatever changes will be done at the Datasource end that will be directly available to the tableau desktop.
To create a data source filter On the data source page, click Add in the Filters section in the upper-right corner of the page. To create a data source filter on a worksheet, right-click (control-click on a Mac) the data source and choose Edit Data Source Filters.
in your onRequestStart method of your Application.cfc file or in an Application.cfm file you can run a simple query to check that the database is available. Wrap the query in cftry/cfcatch. If the query fails, you can redirect the user in the cfcatch, if it succeeds, you can be reasonably sure that your database is "alive".
I've used such a check in one project. Code may looks as follows (not sure if it will work in versions of ColdFusion lower than 8), consider this sample as chunk of UDF written in CFScript:
// service factory object instance
factory = CreateObject("java","coldfusion.server.ServiceFactory");
// the datasource service
dsService = factory.DatasourceService;
// verify the dsn
return dsService.verifyDataSource(arguments.dsn);
Oh, I have even found small note in the code I wrote on my old laptop couple of years ago:
// [performance note] this server check takes 1-3ms at local PC (Kubuntu 7.10, CF8 + Apache2, Sempron 3500+, 1GB RAM)
While time looks like small I have found out that doing this check on each request is not really useful for my application. Any way I have a habit to use the try/catch extensively for errors handling. But if your datasources may cheange frequently it may have more sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With