编程语言
首页 > 编程语言> > 使用Java / Jackcess从加密的Access .mdb中读取

使用Java / Jackcess从加密的Access .mdb中读取

作者:互联网

我需要从加密的Access 97数据库中读取数据并尝试使用Jackcess和UCanAccess.

我正在使用来自bouncycastle.org的jackcess-2.1.2.jar,jackcess-encrypt-2.1.0和bcprov-jdk15on-152.jar

由于UCanAccess在内部使用Jackcess,我在其他所有尝试中都遇到了同样的错误.

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();

最后一行调用错误,这里是堆栈跟踪:

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)

解决方法:

事实证明,虽然jackcess-encrypt与bouncycastle 1.52源兼容,但它不是二进制兼容的.有关更多详细信息,请参见此feature request.基本上(现在),您需要使用1.50或更低版本的bouncycastle.

更新:从jackcess-encrypt的2.1.1版本开始,bouncycastle的旧版本(1.52之前版本)和更新版本(1.52版本)应该正常工作.

标签:java,encryption,ucanaccess,ms-access-97,jackcess
来源: https://codeday.me/bug/20190829/1763196.html