以下代碼總是返回1.我不明白爲什麼。在java中執行mysql restore cmd runtimeProcess.waitFor()總是返回1
String executeCmd[] = {"mysql"," -u" + dbUser," -p" + dbPass," -A"," -D"+dbName ," < " + restorePath};
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if (processComplete == 0) {
System.out.println("Successfully restored from SQL : " + s);
} else {
System.out.println("Error at restoring");
}
你在Windows或Linux上運行? – Reimeus
我在linux環境下。 – Bee
輸入重定向(「<」)由shell(「bash」)處理,而不是由您的操作系統處理。 – dummy