The Java code calls the cmd command to execute the MySQL script result, the cmd command returns a result of the problem of 1:
Process process = Runtime. getruntime (). EXEC (cmd);
int waitFor = Process.waitfor ();
The top waitfor value is 1, and the value is 0 is normal, then how can I know this execution result is because of what is wrong? The error message can be printed out, the process object has an abnormal flow, print a bit better:
FileInputStream Errorstream = (fileinputstream) process.geterrorstream (); InputStreamReader ISR = new InputStreamReader (Errorstream, "GBK");//Read System.out.println (isr.getencoding ()); BufferedReader bufr = new BufferedReader (ISR);//buffer String line = null; while (line =bufr.readline ())!=null) { System.out.println (line); } Isr.close ();
The result is that the printed statement is: Mysqldump is not an internal command ...
It can be found that the result of the execution is incorrect because the MySQL command is not available to use, to find this reason.
Java code Execution cmd return value exception