Skip to main content
Inspiring
September 27, 2012
Question

Connect Coldfusion to a dbf file

  • September 27, 2012
  • 1 reply
  • 2742 views

Hello

I'm trying to set up a connection to a dbf file. Don't ask me what kind of dbf. Most probably NOT FoxPro but may be "open" dbf.

First I tried to set up a data source connection in the Coldfusion administration interface. I was choosing "DB2" as database type but I did not understand how to fill in the fields. Then I tried without setting up a data source connection and I found on the web something like:

<CFQUERY

NAME="myquery" DBTYPE="dynamic" CONNECTSTRING="Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=C:\Inetpub\wwwroot\dbf\sample.dbf;">

SELECT * FROM ???????

</CFQUERY>

Puhhhhhh, I do not understand this stuff. Can somebody help me out?

Thank you

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
October 23, 2012

No, that wont work. The cfquery tag wont accept ConnectString as an attribute or a dbType called Dynamic.

Your first instincts were right. Start by creating a DB2 datasource in the administrator. That is where you have to fill in all the driver/connection information.

Let us suppose that you named the datasource myDSN. Your ColdFusion code will then be something like this

<CFQUERY NAME="myquery" DATASOURCE="myDSN">

SELECT *

FROM tableName

</CFQUERY>

Inspiring
October 23, 2012

Thank you for your suggestion.

I still cannot make it work. In CF Admin I tried to set up a database connection:

      
  

The connection did throw error not being able to connect. I'm not sure about the alredy set Port???

Is there any further input?

Thank you...

BKBK
Community Expert
Community Expert
October 23, 2012

First off, I should tell you I don't use DB2. I am only relying on my experience with installing other datasources in ColdFusion.

There are 3 possibilities. The first two involve using ColdFusion's built-in DB2 driver. The settings are

CF Data Source Name: myDSN

Database: DB2

Server: Localhost

Port: 50000  

User name: your_username

Password: your_password

or

JDBC URL: jdbc:macromedia:db2://localhost:50000;DatabaseName=myDatabase;sendStringParametersAsUnicode=false;StripNewLines=true

Driver Class: macromedia.jdbc.MacromediaDriver 

Driver Name: DB2

Port: 50000 

User name: your_username

Password: your_password

The third possibility is quite common. It seems that DB2 enthusiasts prefer it because it is easier to install. It involves installing a separate driver yourself. A previous thread in this forum shows for example how to install the IBM DB2 driver in ColdFusion. The settings then go like this:

JDBC URL:  jdbc:db2://MyServerName:MyPort/MyDBName

Driver Class: com.ibm.db2.jcc.DB2Driver

Driver name: DB2

User name: your_username

Password: your_password

You can find plenty more, courtesy of Google. In case you wish to know the list of built-in database drivers in ColdFusion, then run the following code:

<cfset adminObj = CreateObject("component","cfide.adminapi.administrator")>

<cfset adminLogin = adminObj.login("your_admin_password")>

<cfset datasourceService = CreateObject("component","cfide.adminapi.datasource")>

<cfset driverDetails = datasourceService.getdriverdetails()>

<cfdump var="#driverDetails#">

Postscript: The ColdFusion 10 support matrix says that DB2 is supported by ColdFusion's Enterprise version, not by the Standard version.