• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Connect Coldfusion to a dbf file

Participant ,
Sep 27, 2012 Sep 27, 2012

Copy link to clipboard

Copied

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

TOPICS
Database access

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2012 Oct 23, 2012

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 23, 2012 Oct 23, 2012

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2012 Oct 23, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 09, 2012 Nov 09, 2012

Copy link to clipboard

Copied

LATEST

Not sure if you are still having this problem, I just ran across your posting.  I think there is confusion in the stream of responses over the type of database you are using.  Whenyou say "db2" I think that maybe you are referring to "dbaseII" and not IBM's "DB2" rdms product.  If you have a dbf file, it is probably dBaseII.  You should be able to use the Windows ODBC driver to connect to it, and then setup the CF datasource to use the ODBC driver.  If you are using CF10/64 bit then see recent posting on the general topic of connecting to 32-bit drivers.

hth,

reed

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation