VerifyDSN(dsn)
Last updated July 01, 2002
Version: 1 | Requires: CF6 | 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:
<CFOUTPUT>
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 Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016