StarQuest Technical Documents

Using StarSQL with ColdFusion

Last Update: 3 October 2008
Product: StarSQL
Version: StarSQL 5.x or later
Article ID: SQV00SQ047


StarSQL can be used with ColdFusion MX 7 and ColdFusion 8 applications to access DB2 data. This document explains how to configure a data source in ColdFusion to use StarSQL and provides sample code.


Follow the steps below to configure a data source in ColdFusion so you can use StarSQL for Java to access DB2 data from a ColdFusion application.

  1. Launch the ColdFusion Administrator and enter the administrator login credentials.
  2. On the left pane, expand DATA & SERVICES and select Data Sources.
  3. In the Add New Data Source section, enter a name (such as "DB2Prod") to be used for the new ColdFusion data source, select ODBC Socket for the Driver, and click Add.
  4. In the ODBC Socket configuration, select the StarSQL DSN from the ODBC DSN drop down list. If you do not see your StarSQL DSN listed, verify that you are using a StarSQL System DSN, not a User or File DSN.
  5. Enter a DB2 UserID and Password.
  6. Enter an optional description, set Advanced Settings (if desired), and click Submit.
  7. After the connection has been added to the Connected Data Sources list, verify that the status of the data source is OK. If not OK, correct any errors reported and use the Verify button (icon with the green check mark) to test connectivity.

In your application, refer to the ColdFusion data source using the ColdFusion Data Source Name (created in Step 3), not the StarSQL Data Source Name. The following sample code demonstrates how to use the Data Source in the cfquery function.

<title>Sample ColdFusion Application</title>

<!Specify the Data Source Name and SQL statement in the cfquery function>

<cfquery name="Dataset" datasource="DB2Prod">

<!Display the result set in a table>

<table border="1">
<cfoutput query="DataSet">
<cfloop index="Columns" list="#DataSet.ColumnList#">



The information in technical documents comes without any warranty or applicability for a specific purpose. The author(s) or distributor(s) will not accept responsibility for any damage incurred directly or indirectly through use of the information contained in these documents. The instructions may need to be modified to be appropriate for the hardware and software that has been installed and configured within a particular organization.  The information in technical documents should be considered only as an example and may include information from various sources, including IBM, Microsoft, and other organizations.