Jackcess 加密似乎无法打开提供的文件。
这是代码。 我要做的是打开受密码保护的数据库并将指定的表导出为 .csv 文件。
public class DBTool {
private final String source = "/Users/myMac/Desktop/database.mdb";
private final String destination = "/Users/myMac/Desktop/table.csv";
private File sourceF;
private File destinationF;
private Database db;
public DBTool() {
}
public void openEDB(){
sourceF = new File(source);
try {
db = new DatabaseBuilder(sourceF)
.setCodecProvider(new CryptCodecProvider("password"))
.open();
} catch (IOException ex) {
Logger.getLogger(DBTool.class.getName()).log(Level.SEVERE, null, ex);
}
}
public void exportDB(){
sourceF = new File(destination);
try {
ExportUtil.exportFile(db, "TableName", destinationF);
} catch (IOException ex) {
Logger.getLogger(DBTool.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
以下是 我似乎无法弄清楚如何简单地打开要导出的文件的错误。
java.io.IOException: Empty database file
at com.healthmarketscience.jackcess.impl.JetFormat.getFormat(JetFormat.java:276)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:378)
at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:248)
at accesstoolssim.DBTool.openEDB(DBTool.java:30)
at accesstoolssim.AccessToolsSim.main(AccessToolsSim.java:9)
Exception in thread "main" java.lang.NullPointerException
at java.io.FileOutputStream.<init>(FileOutputStream.java:203)
at java.io.FileOutputStream.<init>(FileOutputStream.java:162)
at java.io.FileWriter.<init>(FileWriter.java:90)
at com.healthmarketscience.jackcess.util.ExportUtil.exportFile(ExportUtil.java:204)
at com.healthmarketscience.jackcess.util.ExportUtil.exportFile(ExportUtil.java:172)
at accesstoolssim.DBTool.exportDB(DBTool.java:39)
at accesstoolssim.AccessToolsSim.main(AccessToolsSim.java:10)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)