0

我有一个 ms 访问数据库“abc.accdb”,其密码为“abcdabcdef”。尝试通过以下命令使用 Jackcess Encrypt 打开它:

package com.sample;
import java.io.File;
import java.io.IOException;
import com.healthmarketscience.jackcess.CryptCodecProvider;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import com.healthmarketscience.jackcess.Row;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.impl.CodecProvider;

public class Test {
    public static void main(String[] args) throws IOException {
        CryptCodecProvider cryptProvider = new CryptCodecProvider("abcdabcdef");
        Database db = new DatabaseBuilder(new File("abc.accdb")).setCodecProvider((CodecProvider) cryptProvider).open();
        Table table = db.getTable("Checklist");
        for(Row row : table) {
          System.out.println("Column 'Company' has value: " + row.get("Company"));
        }
    }
}

我得到以下异常:

Exception in thread "main" java.lang.IllegalStateException: com.healthmarketscience.jackcess.impl.office.EncryptionHeader@1af7c57 key size is outside allowable range
    at com.healthmarketscience.jackcess.impl.office.EncryptionHeader.read(EncryptionHeader.java:185)
    at com.healthmarketscience.jackcess.impl.office.RC4CryptoAPIProvider.<init>(RC4CryptoAPIProvider.java:55)
    at com.healthmarketscience.jackcess.impl.OfficeCryptCodecHandler.create(OfficeCryptCodecHandler.java:121)
    at com.healthmarketscience.jackcess.CryptCodecProvider.createHandler(CryptCodecProvider.java:117)
    at com.healthmarketscience.jackcess.impl.PageChannel.initialize(PageChannel.java:120)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:511)
    at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:386)
    at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:170)
    at com.sample.Test.main(Test.java:14)

我应该如何打开我的数据库文件?“密钥大小超出允许范围”异常是否有解决方法?请记住,我不允许更改文件的密码。

4

1 回答 1

0
Database db = new DatabaseBuilder(myDbFile).setCodecProvider(new CryptCodecProvider("MyDbPassword")).open();

使用http://jackcessencrypt.sourceforge.net中提到的上述代码。这可能会奏效。

于 2015-07-24T18:07:35.143 回答