以下は私のコードです.なぜそれが機能していないのかわかりません.デバッグした後、runtimeProcessが「java.lang.ProcessImpl@1afe17b」を返し、processCompleteが1を返すことがわかりました. .exec に渡しています。助けてください。
public static boolean backupDB(String Database, String Dbuser, String Password) throws IOException, InterruptedException
{
Process runtimeProcess;
try{
runtimeProcess = Runtime.getRuntime().exec(new String[]{"cmd.exe", "/C","C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\mysqldump.exe -u"+Dbuser+" -p"+Password+Database+" >F:\\backup.sql"});
System.out.println(runtimeProcess);
int processComplete = runtimeProcess.waitFor();
System.out.println(processComplete);
if (processComplete == 0) {
System.out.println("Backup created successfully");
return true;
}
else{
System.out.println("Could not create the backup");
}
}catch (Exception ex)
{
ex.printStackTrace();
}
return false;