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 | 1778 Views

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .