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
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>
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...
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.
Copy link to clipboard
Copied
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