正如我从apache 手册中读到的,我尝试使用以下代码恢复我的嵌入式 Java DB (AKA Derby) 数据库:
private void restoreBackup() {
FileDialog fileDialog = new FileDialog(new Frame(), "Choose A Backup Folder)", FileDialog.LOAD);
//fileDialog.setDirectory("::myVolume:");
fileDialog.setVisible(true);
String fileName = fileDialog.getDirectory();
if (fileDialog.getDirectory() != null) {
fileName = fileName.substring(0, fileName.lastIndexOf(System.getProperty("file.separator")));
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Properties connectionProps = new Properties();
connectionProps.put("restoreFrom", fileName);
connectionProps.put("user", "pass");
connectionProps.put("password", "databaseName");
conn = DriverManager.getConnection(dbURL, connectionProps);
conn.commit();
System.out.println("Database Restored");
} catch (InstantiationException ex) {
Logger.getLogger(ReseachAssistantUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(ReseachAssistantUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(ReseachAssistantUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(ReseachAssistantUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
但是,即使没有抛出异常,也没有任何反应。我在这里做错了吗?