Reading Visual Foxpro Data From Java using ODBC

旧街凉风 提交于 2019-12-04 17:16:48

I was able to access a FoxPro table with the jdbc-odbc bridge on Windows 7 but it took a number of steps. I already had the VFP driver installed, and I don't remember where I downloaded it from, so I don't have a link for that.

I copied the code from a jbdc:odbc example here: http://www.java2s.com/Code/Java/Database-SQL-JDBC/SimpleexampleofJDBCODBCfunctionality.htm.

The DriverManager.getConnection method takes a database URL. To create a URL you need to use the ODBC manager. Unfortunately for me, the ODBC manager that I could get to through the control panel only worked for 64 bit data sources. I am not aware of a 64 bit foxpro driver.

To generate a 32 bit DSN you need to run the 32 bit ODBC manager: odbcad32.exe. My machine had several copies. I ran the one from C:\Windows\SysWOW64. Go to the System DSN tab and select the Microsoft Visual Foxpro Driver. When you click finish, you will get a dialog that asks for a Data Source Name, description and path to the FoxPro database or tables. You also have to specify whether you want to connect to a .dbc or a free table directory. Your error message makes me wonder if you had the wrong option selected on your DSN.

The database URL I passed in to the getConnection method was "jdbc:odbc:mydsnname".

After I ran this, I received an error:

[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

This was because I was using a 64 bit JVM with a 32 bit DSN. I downloaded a 32 bit JVM and was able to use it to run my sample class.

I do not know if there is a switch you can set on a 64 bit JVM to tell it to run as 32 bit.

Morkus

I used the JDBC driver from here:

http://www.csv-jdbc.com/relational-junction/jdbc-database-drivers-products/new-relational-junction-dbf-jdbc-driver/

Works fine for me. In testing so far (about an hour), it reads MEMO files and seems to have had no issues with either DBC-containted tables or free DBFs.

Not sure how much this driver costs. The client will only probably pay $100 max since VFP is beyond obsolete.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!