CFLib.org – Common Function Library Project

GetDSN(dsn)

Last updated January 6, 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>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson