July 14, 2004

Verify a dsn connectivity on the fly

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>

Posted by Elyse at July 14, 2004 9:46 PM | TrackBack
Comments

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

Posted by: barry.b at July 19, 2004 8:57 AM

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

Posted by: Elyse at July 23, 2004 9:23 PM
Post a comment









Remember personal info?