Access Visual FoxPro database from Java

£可爱£侵袭症+ 提交于 2019-11-28 09:30:14

I found the way to do it.

I ended up using JACOB (from here).

  1. Downloaded and installed Visual FoxPro OLE DB driver from http://msdn.microsoft.com/en-US/vfoxpro/bb190232. the direct link is: Microsoft OLE DB Provider for Visual FoxPro 9.0 SP2
  2. Downloaded JACOB version 1.17 binary and source code.
  3. Added jacob.jar as a Java Build Path library
  4. Copied jacob-1.17-x86.dll to the project directory (same place as eclipse's .project file)
  5. Copied jacob-1.17_src\jacob-1.17\samples\com\jacob\samples\ado contents to my src directory and:
    1. Removed the ms directory
    2. renamed test.java to Main.java
    3. Changed the connection string to: String connectStr = "Provider=vfpoledb;Data Source=C:\\path\\to\\Data\\;Collating Sequence=general;";
    4. Changed the queryStr to match one of the dbf's name

Hope this helps someone else.

You may find interesting to use a jdbc driver for foxpro files. I made some quick tests with this one, and it almost looks like you are using a real database in Java.

Regards,

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