CFLib.org – Common Function Library Project

GetDSN(dsn)

Last updated January 06, 2004

author

Martin Parry

Version: 1 | Requires: CF6 | Library: UtilityLib

Description:
Gets the configuration of an existing datasource.

Return Values:
Returns a structure.

Example:

<cfset dsStructure = getDSN("mydatasource")>
<cfdump var="#dsStructure#">

Parameters:

Name Description Required
dsn The name of the datasource. Yes

Full UDF Source:

<!---
 Gets the configuration of an existing datasource.
 
 @param dsn      The name of the datasource. (Required)
 @return Returns a structure. 
 @author Martin Parry (martin.parry@beetrootstreet.com) 
 @version 1, January 6, 2004 
--->
<cffunction name="getdsn" returntype="struct" output="false">
    <cfargument name="dsn" type="string" required="yes">

    <!--- initialize variables --->
    <cfset var dsservice = "">

    <!--- get "factory" --->
    <cfobject action="create"
             type="java"
             class="coldfusion.server.ServiceFactory"
             name="factory">

    <!--- get datasource service --->
    <cfset dsservice = factory.getdatasourceservice()>

    <cfif not structKeyExists(dsservice.datasources,dsn)>
        <cfthrow message="#dsn# is not a registered datasource.">
    </cfif>
    
    <!--- get dsn --->
    <cfreturn duplicate(dsservice.datasources[dsn])>

</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

Created by Raymond Camden / Design by Justin Johnson