Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Application-wide datasource in Railo

Another one of those features that I knew was is in CF 9 but didn't know was in Railo and thats Application wide datasource name.

What this means is that in your Application.cfc (NOT .cfm!) you can set a per-application datasoure which lets you ommit the "datasource" attribute in your <cfquery> tags.

Your Application.cfc

view plain print about
1<cfcomponent displayname="Application.cfc">
2<cfscript>
3    // Set the application name
4
    this.name = "myApp" & hash(getCurrentTemplatePath())
5    
6    // Set the datasource
7
    this.datasource = "myDSN";
8    
9
</cfscript>
10</cfcomponent>

Your test.cfm page

view plain print about
1<cfquery name="qry">
2        SELECT * FROM yourTable
3    </cfquery>
4    <cfdump var="#qry#" label="Query Dump">

Comments Comments (0) | Print Print | Send Send | 1891 Views

If you like what you see on the website and/or this post has helped you out in some way please consider donating to help keep me in beer vodka. The donations are made through Paypal, which accepts almost any credit card or eCheck.

(Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .