How to Create a ColdFusion Data Source – Tutorial!

Share Button

Data Source ToolTo connect to an existing database through ColdFusion you will first need to set up a data source through the ColdFusion administrator. You can think of a data source as a sort of interpretor between your ColdFusion code and the database you are connecting to. In the example below, I am using ColdFusion 9 administrator settings, however, if you are on earlier or later versions the process is almost identical to setup so you should be able to follow along easily.

1. Log in to your ColdFusion administrator using your administrator password. If you have followed standard installation procedures you can typically find your administrator log in at http://<www.yoursite.com>/CFIDE/administrator/

ColdFusion Administrator Log In Screen

2. In the left navigation panel, expand the “Data & Services” menu and click on “Data Sources”. The next screen should show you a list of all your current data sources you have created as well as an option to “Add New Data Source”.

3. We are going to connect to a SQL database in this example, so enter a data source name and select the Microsoft SQL Server driver from the drop down menu. If you are creating a data source for a different database type, just select the appropriate database driver for your database. When you are finished click the “Add” button.

Add New Data Source

4. The next screen will allow you to specify all of your server specific settings such as the name of the database you wish to connect to, the server address, your username and password as well as some advanced options. If you aren’t sure of these values or you are not hosting the database yourself, you may need to contact your database administrator to obtain this information. You can click the “Show Advanced Settings” as an optional way to specify other parameters for your connection but usually this isn’t required.

Add New Data Source

5. Once you have filled in the all the required fields, click the “Submit” button and ColdFusion will verify the connection and you will be taken back to the original screen that listed all of your current data sources. If all went well and you supplied the correct information on the previous screen, you should see “ok” next to your data source. However, if you have supplied incorrect information or your data source didn’t connect successfully, you may see an error like the one below.

ColdFusion Data Source Error

If you receive no errors, you can now use this data source to query your database through Coldfusion.


Leave a Reply

Your email address will not be published. Required fields are marked *