VerifyDSN(dsn)
Last updated July 1, 2002
Version: 1 | Requires: ColdFusion MX | Library: DatabaseLib
Description:
Verifies a DSN is working. It will verify whether the specified DSN is working, not whether it exists. This UDF uses the coldfusion.server.ServiceFactory object.
Return Values:
Returns a Boolean.
Example:
Is CFLib.org's main DSN working?: #VerifyDSN("#Request.App.dsn#")#
</CFOUTPUT>
Parameters:
| Name | Description | Required |
|---|---|---|
| dsn | Name of a DSN you want to verify. | Yes |
Full UDF Source:
<!---
Verifies a DSN is working.
@param dsn Name of a DSN you want to verify. (Required)
@return Returns a Boolean.
@author Ben Forta (ben@forta.com)
@version 1, October 15, 2002
--->
<CFFUNCTION NAME="VerifyDSN" RETURNTYPE="boolean">
<CFARGUMENT NAME="dsn" TYPE="string" REQUIRED="yes">
<!--- initialize variables --->
<CFSET var dsService="">
<!--- Try/catch block, throws errors if bad DSN --->
<CFSET var result="true">
<CFTRY>
<!--- Get "factory" --->
<CFOBJECT ACTION="CREATE"
TYPE="JAVA"
CLASS="coldfusion.server.ServiceFactory"
NAME="factory">
<!--- Get datasource service --->
<CFSET dsService=factory.getDataSourceService()>
<!--- Validate DSN --->
<CFSET result=dsService.verifyDatasource(dsn)>
<!--- If any error, return FALSE --->
<CFCATCH TYPE="any">
<CFSET result="false">
</CFCATCH>
</CFTRY>
<CFRETURN result>
</CFFUNCTION>
Search CFLib.org
Latest Additions
Raymond Compton added
structBlend
19 day(s) ago
Duncan added
IsZIPUK
19 day(s) ago
Todd Sharp added
getTagContentAll
25 day(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago
Gerald Guido added
ListReturnDuplicat...
1 month(s) ago