Connecting ColdFusion 10 to FoxPro 9

My company has a legacy application built in FoxPro 9 which contains a table that I need to extract data from on a recurring basis. I have never worked with FoxPro. Apparently in FoxPro each table has a corresponding .dbf file. For this example we will say that the table file is persons.dbf, which resides at C:\legacyapp\data\.

The first step for connecting ColdFusion to the FoxPro database was to find an acceptable driver. I initially tried to use some ODBC drivers but abandoned this route. Not only was it just not working, but I do my development on a Mac (whereas production is Windows) and I really wanted a solution that did not involve a Windows and a Mac configuration.

So the following steps describe how I set up a jdbc connection to FoxPro 9 from ColdFusion.

  1. Download the StelsDBF JDBC Driver
  2. Place the dbfdriver.jar file in {ColdFusion-Home}/cfusion/lib aka C:\ColdFusion10\cfusion\lib\
  3. Restart the ColdFusion services
  4. Login to the CFADMIN and set up a Data Source
    • For ‘Data Source Name’ enter ‘legacyapp’
    • For ‘Driver’ select ‘Other’
    • Click ‘Add’
    • For JDBC URL enter ‘jdbc:jstels:dbf:c:/legacyapp/data’
    • For Driver Class enter ‘jstels.jdbc.dbf.DBFDriver2’
    • Click ‘Submit’
  5. When using cfquery to select data use the file name as the table name:
    SELECT 
        LASTNAME, FIRSTNAME
    FROM
        persons
    

It was actually not too bad to set up once I located the driver.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.