Andy Jarrett // Code. Develop. Create.

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

<cfcomponent displayname="Application.cfc"><cfscript> // Set the application name this.name = "myApp" & hash(getCurrentTemplatePath()) // Set the datasource this.datasource = "myDSN"; </cfscript></cfcomponent>

Your test.cfm page

<cfquery name="qry"> SELECT * FROM yourTable </cfquery> <cfdump var="#qry#" label="Query Dump">

I’m here, learning and working away. If you liked this content and want to keep me going, consider buying me a coffee. Your support keeps this site running and the coffee brewing! ☕️