Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:59:50+00:00 2026-06-11T14:59:50+00:00

I usually set application-wide datasource name in the Application.cfc first rows: <cfscript>THIS.datasource=mydsn;</cfscript> What if

  • 0

I usually set application-wide datasource name in the Application.cfc first rows:

<cfscript>THIS.datasource="mydsn";</cfscript>

What if I need to change it in certain part of my code?

To be specific, I mean:

  • if the cgi.server_name equals “www.firsturl.com” => this.datasource = “firstdsn”
  • if the cgi.server_name equals “www.secondurl.com” => this.datasource = “seconddsn”

Can I do that for each request?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:59:51+00:00Added an answer on June 11, 2026 at 2:59 pm

    OK, my comment on your original post notwithstanding – that the best way to find out these things is just try it and see what happens, the answer is: yes.

    Application.cfc is poorly named, because it implies it’s kind of application-specific, but in reality the entire thing is instantiated every request. That some of the event handlers only run in given situations (onApplicationStart / onSessionStart etc) is neither here nor there: the whole thing runs every request. So as with any CFC being instantiated, the pseudo-constructor code (where you make your this-scoped variable declarations) is also run every request.

    This means that yes you can conditionally set any of those variables based on REQUEST-specific information (request, CGI, URL, FORM etc; but not APPLICATION or SESSION). So your condition based on a CGI variable will work just fine.

    But don’t take my word for it: try it! Always try these things.

    Finally, just to plug myself slightly, I discuss when things run in Application.cfc in some depth on my blog, in this article. Maybe give it a read, and perhaps look at the other articles on Application.cfc whilst you’re there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My C# application has a comboBox with a SelectedIndexChanged event. Usually, I want this
I usually use the Ruby on Rails framework but for this project I need
I have been trying the model-first method when designing my application. We usually like
I'd usually set some command line arguments to the application which I want to
Well, in our application this usually works fine. But at some point, none of
In my Core Data app I am using a FetchedResultsController. Usually to set titles
I usually have the tw=80 option set when I edit files, especially LaTeX sources.
Usually, I try to set my folders to have permission 775, but some web-hosting
Usually I type m immediately followed by c to set a marker (tag) c
When plotting color-maps using gnuplot, I usually use the following lines: ... set palette

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.