从Java访问Visual FoxPro数据库 [英] Access Visual FoxPro database from Java

查看:579
本文介绍了从Java访问Visual FoxPro数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图从Java访问Visual Fox Pro数据库一周。我变得绝望,因为我的项目预算和时间框架非常紧密。 (正如任何其他项目,我猜,哈哈哈)

I've been trying to access a Visual Fox Pro database from Java for a week now. I'm getting desperate because my project is in a very tied budget and timeframe. (As any other project, I guess, hahaha)

我有一个 .dbf ,一个 .cdx 和一个 .fpt 文件。我需要能够查找记录,提取数据和更新数据。我没有VFP许可证。

I have a .dbf, a .cdx and a .fpt files. I need to be able to look for a record, extract data, and update data. I don't have a VFP licence.

我希望有人可以使用一些指针或工作示例。如果唯一的方法是购买一个司机我会愿意根据收到的建议来考虑。

I hope someone has some pointers or a working example that I can use. If the only way is buying a driver I'll be willing to consider it based on suggestions received.

这是我试过的简短描述。

This is a short description of what I have tried.

我发现这个 xBaseJ:java对象读取和写入dBase文件。但它并没有支持CDX索引文件。

I found this xBaseJ: java objects to read and write to dBase files. But it doesn't suport CDX index files.

还发现了这个示例访问dbf 。但是我的测试显示了这个异常: java.sql.SQLException:[Microsoft] [Controlador ODBC dBase] La tabla externa no tiene el formato esperado。
我猜一个这个错误的英文翻译可能是这样的: java.sql.SQLException:[Microsoft] [ODBC dBase Driver]外部表格不是预期的格式

Also found this Example to access a dbf. But my tests show this exception: java.sql.SQLException: [Microsoft][Controlador ODBC dBase] La tabla externa no tiene el formato esperado. I guess a translation to english of this error could be something like: java.sql.SQLException: [Microsoft][ODBC dBase Driver] External table is not in the expected format

由于这个错误,我想我需要一个更新的驱动程序。在这个微软页面中说他们不再拥有ODBC驱动程序,每个人都应该使用OLE DB提供程序。问题是我还没有找到一种从java中使用它的方法。

Because of that error I think I need a newer driver. In this microsoft page say they no longer have an ODBC driver, and everybody should use OLE DB Provider. The problem is I haven't found a way to use it from java.

据我所知,没有办法直接做到这一点。找到这里有人在谈论JACOBthingy,并有人发表评论关于需要创建C ++或C#某事以便能够做我需要的事情。我认为他在谈论 JACOB项目:JAva-COM桥梁。但我也不知道COM调用实际上要做什么。

As far as I can tell, there is no way to do it directly. Found here someone talking about a JACOB "thingy", and someone comments about the need to create a C++ or C# "something" to be able to do what I need. I think he is talking about The JACOB Project: A JAva-COM Bridge. But I also don't know what COM calls would actually have to make.

无法找到合适的JDBC驱动程序。

Haven't been able to find a suitable JDBC driver.

谢谢大家。

Ely。

推荐答案

我找到了办法。

我最终使用了JACOB(从这里)。

I ended up using JACOB (from here).


  1. http://msdn.microsoft.com/en-US/vfoxpro/bb​​190232 。直接链接是:用于Visual FoxPro的Microsoft OLE DB提供程序9.0 SP2

  2. 下载JACOB版本1.17二进制文件和源代码。

  3. 已添加 jacob.jar 作为Java Build Path库

  4. jacob-1.17-x86.dll 复制到项目目录(与eclipse的.project文件)

  5. 复制 jacob-1.17_src\jacob-1.17 \samples \ com \ _jacob \ examples &\ 我的src目录的内容和:
  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. 删除 ms 目录

  2. test.java 重命名为 Main.java

  3. 更改了连接字符串:
    String connectStr =Provider = vfpoledb; Data Source = C:\\path\\to\\Data\\;整理顺序= general;;

  4. 更改了queryStr以匹配其中一个dbf的名字

  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


希望这有助于其他人。

这篇关于从Java访问Visual FoxPro数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆