Java code Execution cmd return value exception

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.