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
Tayo Akinmade added
arrayTrim
4 day(s) ago
Will Belden added
longTime
9 day(s) ago
James Sleeman added
quickSort
19 day(s) ago
Ben Forta added
GetHostAddress
22 day(s) ago
Top Rated
EksporSQLData
Rated 5.0, 16 time(s)
backupDatabase
Rated 5.0, 13 time(s)
indentXml
Rated 5.0, 10 time(s)
generateSsccAsn
Rated 5.0, 4 time(s)