BerkeleyDB数据库文件打开(java)
我有一个带有 .tld 扩展名的 BerkeleyDB 数据库(eBay Turbolister 文件)。 Linux 命令“file”确认这是一个 BerkeleyDB 数据库。
我正在关注 http://download.oracle 上的教程.com/docs/cd/E17277_02/html/collections/tutorial/opendbenvironment.html。
com.sleepycat.je.Environment 构造函数接受目录,而不是文件。读了一下,我发现这个目录应该包含数据库文件和其他文件,例如日志。
我的问题是:如何指定要打开的数据库的文件名 - 或者数据库文件是否需要具有特定的文件名?其次,该文件是否需要位于其自己的目录中?
我在浏览 API JavaDoc 后发现了以下答案的一些补充信息:
com.sleepycat.je.Environment 有以下接受文件名的方法:
public Database openDatabase(Transaction txn,
String databaseName,
DatabaseConfig dbConfig)
I have a BerkeleyDB database with a .tld extension (eBay Turbolister file). Linux command 'file' confirms this is a BerkeleyDB database.
I am following the tutorial at http://download.oracle.com/docs/cd/E17277_02/html/collections/tutorial/opendbenvironment.html.
The com.sleepycat.je.Environment constructor accepts a directory, not a file. Reading a little, I found this directory is supposed to contain the database file and other files such as logs.
My question is: how do I specify the filename of the database to open - or does the database file need to have a specific filename? Second, does the file need to be in its own dir?
Some complimentary information to the answer below I found after browsing the API JavaDoc:
com.sleepycat.je.Environment has the following method that accepts a filename:
public Database openDatabase(Transaction txn,
String databaseName,
DatabaseConfig dbConfig)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您提到的教程适用于 Berkeley DB Java 版。您确定您的数据库文件是用 Java 版创建的吗?
Berkeley DB 的本机版本也有 Java 绑定,但使用本机库。也许这个更适合?
本机版本中包含命令行工具,例如
db_stat
和db_verify
。您可以使用这些工具来检查您的文件,而无需编写程序。The tutorial you mentioned is for the Java Edition of Berkeley DB. Are you sure that your database file is created with the Java Edition?
The native version of Berkeley DB has also a Java binding but uses the native libraries. Maybe this fits better?
Included in the native version are command line tools like
db_stat
anddb_verify
. You can use these tools to check your file without the need to write a program.