# Adding Data Sources for ColdFusion

The process for adding a data source in the ColdFusion Administrator is the same, no matter what type of driver you're using (ODBC, Native, or OLE DB).

| To add a data source to ColdFusion

1. Open the ColdFusion Administrator.

   You see the Server Settings page of the ColdFusion Administrator.

2. Under Data Sources, click the link that specifies the type of data source you want to add:
   - ODBC
   - Native Drivers
   - OLE DB (Available only on Windows NT)

     The Data Sources page appears.

3. Enter a name for the new data source and select a driver from the drop down list.

   Note | Do not name a ColdFusion data source Registry or Cookie, as these words are reserved for use by ColdFusion.

4. Click Add.

   You see the Create Data Source page.

5. Enter the appropriate information about the new data source.

   The information you enter in this page depends on the platform on which ColdFusion is installed and on the driver you specify. For detailed information about options for your driver, see the section for your specific database later in this chapter.

6. Click CF Settings to set the following ColdFusion-specific options. See the following section, "ColdFusion Settings", for detailed information about these settings.
7. Click Create to create the new data source.

   ColdFusion automatically verifies that it can connect to the data source. If the data source is successfully verified, you see the Data Source page, with the new data source listed. If ColdFusion could not verify the data source, you see an error message. For more information about verifying data sources, see "Connecting to Sybase System 11 data sources".

If you are creating a UNIX data source, you may need to set environment variables for your database client library by editing the ColdFusion start script in `<installdir>/coldfusion/bin`. For detailed information about editing the ColdFusion start script for your particular database, see the section about your database in this chapter.

## ColdFusion Settings

To define a number of advanced ODBC and ColdFusion options, select a data source and click the CF Settings button. These options apply to all platforms. The following table describes the ColdFusion data source options.

ColdFusion Data Source Settings
Option | Description
--- | ---
Login Timeout | The amount of time in seconds before ColdFusion times out the connection login page.
Limit Connections | Click to enable and then specify the number of simultaneous connections you want to allow for the current data source. Note: If you enable Limit Connections without specifying a limit for simultaneous connections, ColdFusion defaults to unlimited connections.
ColdFusion Login | Enter a username/password for accessing the ODBC data source. Any username and password specified in a CFQUERY or other data access tag overrides the values specified in the ColdFusion login. Also, when creating a data source using a native database driver, you use the username and password options to pass login information to the database.
Maintain database connections | Ordinarily, a connection to a data source is established for every operation that requires it. However, you can improve performance by caching the database connection. To do so, click to enable this check box.
Disable Database Connections | Disables connections to the data source. This setting is useful if you need to perform administrative tasks to the database. ColdFusion no longer allows users to establish new connections to the disabled data source. In addition, any existing connections that are not in use are automatically disconnected and cleaned up, and any connections currently in use are automatically notified that they are to clean themselves up as soon as their current transaction is complete. Subsequent requests to disabled data sources return trapable database exceptions. To restore the connection to the data source, uncheck this option.
Connection timeout | Specify the maximum amount of time after the database connection is made (in minutes) you want ColdFusion to cache a connection after it is used. This is different from the server setting to Limit database connection inactive time. This latter setting is server wide and only releases cached connections that have been inactive (not used) for the specified period of time. The Connection Timeout setting does not return a connection to the cache after a specified period of time no matter how frequently or infrequently it has been used. The default is "" or 0 which means the connection timeout is never enforced.
Restrict SQL Operations | Select the SQL operations you want to restrict for the current data source. ColdFusion will not execute the SQL operations you select in this list.
Enable retrieval of long text | Retrieves all the data for a long text field. ColdFusion retrieves the column with the long text field and any subsequent columns in the select statement as unbound data. Unbound data takes longer to retrieve than bound data; therefore, enabling this setting can affect performance. If you use this setting, you should order the columns in your select statement with the long text fields referenced last.
Long Text Buffer Size | Specifies the number of characters to retrieve from a long text field if "Enable retrieval of long text" is not set. In this case, ColdFusion binds text columns to a buffer whose size you specify in this field. If you specify a size that is not supported by your database, an SQL execution error occurs when you try to retrieve the data.