Please Share Feedback


Questions, comments, suggestions? Let us know what you think on our Forum.

To contact us privately, please use our contact form.

Author: Elyse, PMP, CPHIMS
July 14, 2004


Every once in a while, you may want to have logic to verify the data source within your code. The following trick will work.

<cfset variables.lockname = CreateUUID() />
<cflock name="#variables.lockname#" type="exclusive" timeout="10">
<cfscript>
factory = CreateObject("java", "coldfusion.server.ServiceFactory");
ds_service = factory.DataSourceService;
isOk = ds_service.verifyDatasource("#Application.dsn#");
</cfscript>
</cflock>

Subscribe and Share!

Did you enjoy this article? Your feedback is very important! I'd like to invite you to keep up to date with the latest posts from Anticlue. We offer several venues. If you have some questions, help can be found here.
 

2 Comments to “Verify a dsn connectivity on the fly”

I was looking for such an idea in a missCrit system BUT...aren't you worried that factory is unsupported? are you really game to put this in proddy code and send it out there?

great idea but i know my boss won't go for it because of that reason. Hell, he's even saying that cfscript will go the way of the dodo...eventually.

no docs from MM = no support = no guarentees...

just 2c worth.
barry.b

Hi,

I agree whole heartily with you. Sometimes just because we can doesn't mean we should. Its a neat trick, but not something I'd deploy at work.

Really depends on the risk nature of the organization.

Elyse


« User Acceptance Why deploy a Content Managment System »

Please share your thoughts and suggestions