我可以从 Java 读取 BerkeleyDB(非 Java 版本)文件吗?
我需要从 Java 读取 BerkeleyDB 文件。
Oracle 有 BerkeleyDB 的官方 Java 版本,但它似乎使用自己的、不兼容的二进制文件格式。
我该怎么办?
I need to read BerkeleyDB files from Java.
Oracle has an official Java Edition of BerkeleyDB, but it seems that this uses its own, incompatible binary file format.
What do I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 Wikipedia 页面,有经典 Berkeley DB 的 Java 绑定,但它们需要使用JNI 和本机库。这是 Sleepycat Berkeley DB - Java API 的链接文档。
According to the Wikipedia page, there are Java bindings for classic Berkeley DB, but they require use of JNI and a native library. Here's a link to the Sleepycat Berkeley DB - Java API documentation.
Berkeley DB 实际上可以以 2 种不同的格式存储数据,具体取决于您是否选择使用 SQL API。 SQL API 是最近添加的,Berkeley DB 历史上一直是键/值数据库。
确实,您需要构建本机库并使用 JNI,但如果您想访问由本机库创建的文件,这是可以预料到的。幸运的是,构建过程非常简单。
如果您在 Windows 下构建,请参阅安装指南。
对于 Linux 或其他 *NIX,解压文件后,请转至 build_unix 目录并执行以下操作之一:
../dist/configure --enable-java - -prefix=/usr/local/db
make install
../dist/configure --enable-sql --enable-jdbc --prefix=/usr/local/db
make install
(显然您可以将 --prefix 替换为您选择的安装位置)
有关详细信息,请参阅 文档页面。
希望对您有所帮助,祝您的项目顺利。
Berkeley DB can actually store data in 2 different formats, depending on whether you elect to use the SQL API or not. The SQL API is a recent addition, Berkeley DB has historically been a key/value database.
It is true that you need to build the native library and use JNI, but this is to be expected if you want to access files created by a native library. Fortunately, the build process is very simple.
If you are building under Windows, please refer to the installation guide.
For Linux or other *NIX, after you have untarred the file go to the build_unix directory and do one of the following:
../dist/configure --enable-java --prefix=/usr/local/db
make install
../dist/configure --enable-sql --enable-jdbc --prefix=/usr/local/db
make install
(Obviously you can replace --prefix with the install location of your choice)
For more information see the docs page.
Hope that helps, good luck with your project.