|
Adding data sources
In
the ColdFusion Administrator, you configure your data sources to
communicate with ColdFusion. After you add a data source to the
Administrator, you access it by name in any CFML tag that establishes
database connections; for example, in the cfquery tag. 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 information about all
ColdFusion server database connections in a single location. In
addition to adding data sources, you can use the Administrator to
specify changes to your database configuration, such as relocation,
renaming, or changes in security permissions.
Adding data sources in the AdministratorYou 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 data sources that are configured
by default. You do not need the following procedure to work with
these data sources.
In the ColdFusion Administrator, select Data & Services
> Data Sources.
Under Add New Data Source, enter a data source name; for
example, MyTestDSN. The following names are reserved; you cannot
use them for data source names:
service
jms_provider
comp
jms
Select a driver from the drop-down list; for example, Microsoft
SQL Server.
Click Add.
A form for additional DSN information appears.
The available fields in this form depend on the driver that you
selected.
In the Database field, enter the name of the database; for
example, Northwind.
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.
If your database requires login information, enter your user
name and password.
Note: The omission of required
user name and password information is a common reason why a data
source fails to verify.
(Optional) Enter a Description.
(Optional) Click Show Advanced Settings to specify any ColdFusion
specific settings; for example, to configure which SQL commands
can interact with this data source.
Click Submit to create the data source.
ColdFusion
automatically verifies that it can connect to the data source.
(Optional) To verify this data source later, click the verify
icon in the Actions column.
Note: To check the
status of all data sources available to ColdFusion, click Verify
All Connections.
Specifying connection string argumentsThe
ColdFusion Administrator lets you specify connection-string arguments
for data sources. In the Advanced Settings page, use the Connection
String field to enter name-value pairs separated by a semicolon.
For more information, see the documentation for your database driver.
Note: The cfqueryconnectstring attribute
is no longer supported.
Guidelines for data sourcesWhen you add data sources to ColdFusion,
keep in mind the following guidelines:
Data source names must be all one word.
Data source names can contain only letters, numbers, hyphens,
and the underscore character (_).
Data source names must not contain special characters or
spaces.
Although data source names are not case sensitive, use a
consistent capitalization scheme.
Depending on the JDBC driver, connection strings and JDBC
URLs might be case sensitive.
Use the Administrator to verify that ColdFusion can connect
to the data source.
A data source must exist in the ColdFusion Administrator
before you use it on an application page to retrieve data.
Connection IssuesExecuting a query when you restart a database can result
in error during the first request. The error does not occur in subsequent
requests or if connection pooling is disabled. This is because,
during the first request, the cached connection is used to execute
the query, leading to an exception. To overcome this issue, validate
the connection before executing the query.
Provide validationQuery (to validate the connection) before executing
the query in the Advanced Settings page. Note: validationQuery has
to be used with caution as it can result in performance issues.
|