这是我为导出数据库创建的代码。问题是,文件没有导出,代码没有显示错误信息。
public boolean exportDatabase(String fromServer,
String FileName,
String FilePath,
int ExportOpions) {
try {
String dbName ="NMSAzzist";
String dbUser = "root";
String dbPass ="root";
String dumbPath = "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\";
String executeCmd = dumbPath+"mysqldump -u "+dbUser+ "-p"+dbPass+" "+dbName+ "-r "+FilePath+ "";
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if (processComplete == 1) { // if values equal 1 process failed
JOptionPane.showMessageDialog(null, "Backup Failed");//display message
} else if (processComplete == 0) {
JOptionPane.showMessageDialog(null, "\n Backup created Successfully..");
// display message
}
return true;
} catch (final Exception ex) {
NmsLogger.writeErrorLog("Database Connection Failed ", ex.toString());
NmsLogger.writeDebugLog(ex);
return false;
}
如何将数据库导出到FilePath
名称中变量中指定的路径FileName
?我该如何解决这个问题?
顺便说一句,我可以使用以下内容导入相同的内容吗?
String[] executeCmd = new String[]{"mysql", databaseName, "-u" + userName, "-p" + password, "-e" + FileName };