我正在尝试阅读eBay Turbolister数据库。通过perl读取键给出:
ItemBLOBs
ItemBLOBs_BLOBIndex
ItemBLOBs_ItemId
Items
Items_FolderId
Items_Modified
Items_Status
ProductVariations
ProductVariations_ITEM_ID
ProductVariations_SYS_SKU
RawDescriptions
VariationPictureBLOBs
VariationPictureBLOBs_BLOBIndex
VariationPictureBLOBs_ItemId
VariationPictureBLOBs_VARIATION_VALUE
VariationPictures
VariationPictures_BLOBOrder
VariationPictures_ItemId
VariationPictures_VARIATION_VALUE
VariationSpecifics
__DATA
__SEQUENCE
阅读价值并不是那么成功。它提供二进制值,其添加长度远小于数据库文件的长度。
我使用的perl脚本是:
#!/usr/bin/perl
use strict;
use BerkeleyDB;
my $filename = 'database';
my %o;
tie %o, "BerkeleyDB::Btree", -Filename => $filename,
-Flags => DB_RDONLY
or die "Cannot open database '$filename: $!\n";
foreach (keys %o)
{ print "$_\n" }
我的最终目标是使用Java,但现在我甚至无法用Java读取密钥。
任何想法如何进行?
一张纸条。对于任何工作解决方案,我必须从BDB Java版切换到本机Java绑定。
答案 0 :(得分:0)
我用Java做的事情如下:
public static void main(final String[] args) throws Exception
{
final EnvironmentConfig environmentConfig = new EnvironmentConfig();
//setup EnvironmentConfig
final DatabaseConfig primaryConfig = new DatabaseConfig();
//setup DatabaseConfig
final SecondaryConfig secondaryConfig = new SecondaryConfig();
//setup SecondaryConfig if necessary
final Database primary = environment.openDatabase(null,
pathToDb, null, primaryConfig);
final DatabaseEntry key = new DatabaseEntry(new byte[ONE_KIBIBYTE]);
final DatabaseEntry value = new DatabaseEntry(new byte[ONE_MEBIBYTE]);
final Cursor cursor = primary.openCursor(null, null);
OperationStatus status = cursor.getFirst(key, value, null);
int count = 0;
while (status.equals(OperationStatus.SUCCESS))
{
++count;
int readId = -1;
int size = -1;
try
{
final TupleInput input = new TupleInput(value.getData(), value
.getOffset(), value.getSize());
size = value.getSize();
readId = input.readInt();
//read other fields from 'input' local variable
if (status.equals(OperationStatus.SUCCESS))
{
status = cursor.getNext(key, value, null);
}
}
catch (final Exception e)
{
throw new RuntimeException(e);
}
}
}