Search code examples
coldfusiondatasourceapplication.cfc

How do I reference a second DB from an application cfc file


In our Portal application.cfc, we are defining (setting up) our DSN connections like so:

<cfset this.datasource = "DSN1"> (Main DB) <cfset this.datasource_1 = "DSN2"> (2nd DB) <cfset this.datasource_2 = "DNS3"> (3rd DB)

These are in the tags. I have also moved then to the ‘OnApplicationStart’ function and cannot get it to work correctly.

This application.cfc if referenced in the main APP, that the other apps have access to (App2, etc…), my question is;

How do I reference the other datasources (this.datasource_2) in a query for the App2 application?

<cfquery name="queryname" datasource="**[What goes here]**"> For second datasource

The this.datasource DSN is always being referenced because there is no datasource listed in the cfquery tags.

Any help you can provide or links to send my way will be appreciated. Thanks in advance!


Solution

  • Try seeing additional application variables

    <cfset application.datasource_1 = "DSN2">  (2nd DB)
    <cfset application.datasource_2 = "DNS3"> (3rd DB)