Adding data sources

In the ColdFusion Administrator, you configure your data sources to communicate with ColdFusion. Once you add a data source to the Administrator, you access it by name in any CFML tag that establishes database connections; for example, cfquery. During a query, the data source tells ColdFusion which database to connect to and what parameters to use for the connection.

The ColdFusion Administrator organizes all the information about a ColdFusion MX server's database connections in a single, easy-to-manage location. In addition to adding new data sources, you can use the ColdFusion Administrator to correct for changes to your database, such as relocation, renaming, or changes in security permissions.

Adding data sources in the Administrator

You use the ColdFusion Administrator to quickly add a data source for use in your ColdFusion applications. When you add a data source, you assign it a data source name (DSN) and set all information required to establish a connection.

Note:   ColdFusion includes several data sources that are configured by default, including cfsnippets, CompanyInfo, and exampleapps. This procedure should not be necessary to work with these data sources.

To add a data source:

  1. In the ColdFusion Administrator, select Data & Services > Data Sources.

    The figure shows the Data Sources page in the Administrator.

  2. Under Add New Data Source, enter a Data Source Name; for example, MyTestDSN.
  3. Select a Driver from the drop-down list box; for example, Microsoft SQL Server.

    The figure shows the Driver drop-down list box.

  4. Click Add.

    A form for additional DSN information appears. The available fields in this form depend on the Driver that you selected.

    The figure shows the form for additional DSN information.

  5. In the Database field, enter the name of the database; for example, Northwind.
  6. In the Server field, enter the network name or IP address of the server that hosts the database, and enter any required Port value; for example, the bullwinkle server on the default port.
  7. If your database requires login information, enter your Username and Password.

    Tip:   The omission of required username and password information is a common reason why a data source fails to verify.

  8. (Optional) Enter a Description.
  9. (Optional) Click Show Advanced Settings to specify any ColdFusion-specific settings; for example, to configure which SQL commands will interact with this data source.

    The figure shows the Advanced Settings for the data source.

  10. Create Submit to create the data source.

    The figure shows the new data source in the list of connected data sources.

    ColdFusion automatically verifies that it can connect to the data source.

  11. (Optional) To verify this data source later, click the verify icon:

    The figure shows the verify data source icon.

    Note:   To check the status of all data sources available to ColdFusion, click Verify All Connections.

Specifying connection string arguments

You can use the ColdFusion Administrator to specify connection string arguments for data sources that use the Microsoft Access,ODBC Socket, MYSQL, or DB2 drivers. In the Advanced Settings page for one of these drivers, enter name=value pairs separated by a semicolon in the Connection String field. The following figure shows how to specify the application name and workstation ID for an ODBC Socket connection to SQL Server:

The figure shows how to specify connection string arguments for Microsoft Access or ODBC Socket drivers.

The Administrator configures the following ODBC connection string:

DSN=odbcdsnname;APP=RaiseGenerator;WSID=TWriter01

In the preceding string, odbcdsnname is the name of the ODBC DSN. This is the string that the Microsoft Access or ODBC Socket driver uses to connect to the data source at runtime.

Note:   The connectstring tag attribute is not supported in ColdFusion MX.

Adding data source notes and considerations

When adding data sources to ColdFusion MX, keep these guidelines in mind:

A data source must exist in the ColdFusion Administrator before you use it on an application page to retrieve data.

Comments