Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Setting the default data source and SMTP

Setting the default data source and SMTP provides you with in-depth training on Developer. Taught by… Show More

ColdFusion 9 New Features

with Daniel Short

Video: Setting the default data source and SMTP

Setting the default data source and SMTP provides you with in-depth training on Developer. Taught by Daniel Short as part of the ColdFusion 9 New Features
Expand all | Collapse all
  1. 4m 30s
    1. Welcome
    2. Using the exercise files
      3m 37s
  2. 7m 49s
    1. Adding managing and comparing servers
      5m 26s
    2. Monitoring server health
      2m 23s
  3. 22m 10s
    1. Setting the default data source and SMTP
      5m 6s
    2. Getting programmatic debugging and exception handling
      5m 54s
    3. Reviewing the new onCFCRequest method
      5m 29s
    4. Using ApplicationStop()
      2m 24s
    5. Working with Server.cfc and onServerStart
      3m 17s
  4. 17m 45s
    1. Using ternary and chained operations
      5m 46s
    2. Using New and Import
      4m 2s
    3. Reviewing CFScript enhancements
      7m 57s
  5. 20m 23s
    1. Building with implicit getters and setters
      4m 26s
    2. Working with LOCAL scope in functions
      4m 35s
    3. Serializing objects
      6m 6s
    4. Writing components in CFScript
      5m 16s
  6. 19m 27s
    1. Getting started with ORM
      5m 51s
    2. Logging ORM activity
      2m 13s
    3. Saving objects to the database
      6m 10s
    4. Defining table relationships
      5m 13s
  7. 16m 59s
    1. Caching page fragments
      5m 29s
    2. Managing the cache
      4m 48s
    3. Working with in-memory files using VFS (RAM disks)
      6m 42s
  8. 12m 39s
    1. Working with Excel spreadsheets
      4m 56s
    2. Working with Word documents
      4m 4s
    3. Working with PowerPoint presentations
      3m 39s
  9. 28m 59s
    1. Loading Google maps with markers onto a page
      4m 53s
    2. Adding a Flash movie with the built-in FLV player
      2m 14s
    3. Using multi-file upload control
      6m 7s
    4. Building a progress indicator
      3m 37s
    5. Working with accordion layouts
      3m 19s
    6. Showing information with data grid enhancements
      5m 1s
    7. Informing users with Confirm Alert and Prompt dialog boxes
      3m 48s
  10. 9m 8s
    1. Accessing IMAP accounts
      6m 31s
    2. Working with the new array functions
      2m 37s
  11. 15s
    1. Goodbye

please wait ...
Setting the default data source and SMTP
Video duration: 5m 6s 2h 40m Intermediate


Setting the default data source and SMTP provides you with in-depth training on Developer. Taught by Daniel Short as part of the ColdFusion 9 New Features

Developer Web

Setting the default data source and SMTP

In this video, I'm going to show you two small but very powerful productivity enhancements in ColdFusion 9, being able to set a default data source and SMTP servers for an entire application. What this means is that in my Application.cfc, I can specify a data source and an SMTP server that get applied to all CF queries and tags in my application if they don't already have that attribute applied. In my Chapter2 Exercise Files folder, we'll open defaultdatasource.cfm and you can see I have a CFQuery that just selects * FROM Artists from the cfartgallery data source.

If I preview that, you can see it's dumping all of my artists to the page. But it is a pain to always put the datasource attribute on every single CFQuery. Normally, you get around this in ColdFusion 8 applications by storing that value in some sort of application scope variable and applying that to every single CFQuery. While that works, there's one more thing that you have to remember to add to every single tag. So, I'm going to remove this entirely. Now if I preview this file, everything falls apart. There is no data source specified.

But if I go to my Application.cfc file, I can now into this scope set this.datasource equals cfartgallery. Now if I go back to default datasource.cfm and preview, I see all of my Artists once again. So, because this CFQuery didn't have a datasource attribute, it inherited it from the value specified in the Application.cfc. Now one thing to keep in mind is that the queries inherit the data source from the application that is calling them, not the application they actually live in.

To show you that, I have an ArtistService.cfc. Now this ArtistService does exactly the same as the other page. It just selects * FROM Artists and it does not have a data source specified. And then in my App2 folder, I have an Application.cfc and it currently has its datasource set to cfartgallery, and showArtists.cfm calls the ArtistService, gets all of the Artists and then dumps them to the page. This page works especially fine because in the Applications.cfc, I have set the datasource to cfartgallery Now if I change the datasource to cfbookclub, I should get an error because Artists table does not exist in the bookclub database.

So I'll go back to showArtists and run the page and we can see that the table, Artists, does not exist. So as you can see I called ArtistService, which is outside of the App2 application, but it did use the data source from this Application.cfc. So as you call external resources, remember that every file that you call is going to use the defaults from the calling application. So the SMTP servers work the same way. I am going to close a couple of files here and the only file I have left open is my Application.cfc here in Chapter2.

So I am going to open the smtpserversettings.cfm and as you can see, I have a tag here with a subject, server, username, and password. So I am sending this mail through my own mail server to my Gmail account. So let's go ahead and preview this in Safari and we are going to see a totally blank page. But if I switch over to my Gmail account, you can see I already have an email that showed up in my Inbox. Now if I go back to CF Builder and remove this information, I'm just going to cut it to my clipboard, save it and preview the file again, I'm going to get an error that says that no SMTP server was specified.

Again, this is something where I would have to go through and every single tag would have to have that server, username, and password information specified. But in CF 9, if I go over to the Application.cfc, I can do the same thing I did with the datasource. I can do cfset this.smtpserversettings equals and I can specify a structure which defines all of that information that I need to supply to the tag. Let's just paste in those attributes I copied and separate them with commas.

Now I've set this.smtpserversettings, I've specified my server, my username, and my password. I'll save this file and go back to the test file and open that one and you see I got a blank page and I switch over here and my email is already in my Gmail. So while it was possible in ColdFusion 8 to wrap up your data source and SMTP server settings in the application variables, you still had to be cognizant of each and every query and tag used to make sure they were used in the correct settings.

In ColdFusion 9, you can just set them in your Application.cfc and only think about them when you need to step outside of the normal operating procedures.

There are currently no FAQs about ColdFusion 9 New Features.






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed ColdFusion 9 New Features.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.