简体   繁体   中英

Reading from an encrypted Access .mdb using Java / Jackcess

I need to read Data from an encrypted Access 97 Database and tried out Jackcess and UCanAccess.

I'm using jackcess-2.1.2.jar, jackcess-encrypt-2.1.0 and bcprov-jdk15on-152.jar from bouncycastle.org

As UCanAccess uses Jackcess internally I'm getting the same error with all my other attempts.

import com.healthmarketscience.jackcess.CryptCodecProvider;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.DatabaseBuilder;
import java.io.File;

File fi = new File("test/access/data.mdb"); 
CryptCodecProvider cryptProvider = new CryptCodecProvider();
cryptProvider.setPassword("mypassword");
DatabaseBuilder dbb = new DatabaseBuilder(fi);
dbb.setFileFormat(Database.FileFormat.V1997);
dbb.setAutoSync(false);
dbb.setCodecProvider(cryptProvider);
dbb.setReadOnly(true);
Database dbc = dbb.open();

the last line invokes an error, here is the Stack Trace:

Exception in thread "main" java.lang.NoSuchMethodError: org.bouncycastle.crypto.StreamCipher.processBytes([BII[BI)V
at com.healthmarketscience.jackcess.impl.BaseCryptCodecHandler.streamDecrypt(BaseCryptCodecHandler.java:91)
at com.healthmarketscience.jackcess.impl.BaseJetCryptCodecHandler.decodePage(BaseJetCryptCodecHandler.java:62)
at com.healthmarketscience.jackcess.impl.PageChannel.readPage(PageChannel.java:224)
at com.healthmarketscience.jackcess.impl.UsageMap.read(UsageMap.java:130)
at com.healthmarketscience.jackcess.impl.PageChannel.initialize(PageChannel.java:117)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:516)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:389)
at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:248)
at ACCESS.ACCESSTest.main(ACCESSTest.java:84)

It turns out that while jackcess-encrypt is source compatible with bouncycastle 1.52, it is not binary compatible. See this feature request for more details. Basically (for now), you need to use a version of bouncycastle 1.50 or lower.

UPDATE: as of the 2.1.1 release of jackcess-encrypt, both older (pre 1.52) and newer (1.52+) versions of bouncycastle should work correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM