ColdFusion Datasource

ColdFusion is a great environment for connecting to, and performing queries against a database. Reasons for using a database could include authentication to a members' area, serving up content from a content management system, logging user feedback, and more.

Any website that uses a database, needs a way to connect to the database and a way to query the database (eg, using SQL Statements).

Create a ColdFusion Datasource

To allow ColdFusion to connect to a database, you first need to create a datasource. A datasource provides the connection between Coldfusion and the database. Another way of looking at it is that the datasource provides the link between your CFML code and the actual database.

You create datasources via the ColdFusion Administrator.

Follow the steps below to create a ColdFusion data source.

  1. Log in to the ColdFusion Administrator (usually at http://{ website_url }/cfide/administrator)
  2. Click on Data Sources. You should see something like this:

    ColdFusion Data Sources  screen

  3. Under Add New Data Source, enter a data source name and driver type (i.e. Microsoft Access, or Microsoft SQL Server). The driver type will depend on your database type.
  4. Click Add
  5. Click Show Advanced Settings (optional)
  6. Enter the details of your database. This screen should look something like this (although will differ depending on the driver you user):

    ColdFusion Data Sources SQL Server details screen

  7. Click Submit

Once you click Submit, ColdFusion will verify the connection to the database. If there are any problems, you should check that the details you entered here match the details of the database (for example, usernames/passwords, server name etc).

Now that you've created a datasource, you can now use the datasource name in your ColdFusion database queries.