I managed to access the FoxPro table with the jdbc-odbc bridge in Windows 7, but it took a few steps. I already have the VFP driver installed and I don’t remember where I downloaded it from, so I don’t have a link for this.
I copied the code from the jbdc: odbc example here: http://www.java2s.com/Code/Java/Database-SQL-JDBC/SimpleexampleofJDBCODBCfunctionality.htm .
The DriverManager.getConnection method accepts the database URL. To create the url you need to use the ODBC manager. Unfortunately, for me, the ODBC manager, with whom I could get through the control panel, worked only for 64-bit data sources. I do not know the 64-bit foxpro driver.
To generate a 32-bit DSN, you need to run the 32-bit ODBC manager: odbcad32.exe. My car had several copies. I ran one of C: \ Windows \ SysWOW64. Click the System DSN tab and select the Microsoft Visual Foxpro driver. When you click Finish, you will get a dialog box asking for the name of the data source, description, and path to the FoxPro database or tables. You must also indicate whether you want to connect to .dbc or a free table. Your error message makes me wonder if you had the wrong option selected in your DSN.
The database url I passed to the getConnection method was "jdbc: odbc: mydsnname".
After that, I received an error message:
[Microsoft] [ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and the Application
This was due to the fact that I used a 64-bit JVM with a 32-bit DSN. I downloaded the 32-bit JVM and was able to use it to run my class.
I do not know if there is a switch that you can set on a 64-bit JVM to say that it works as 32-bit.
source share