Java runtime cannot generate sql file by executing mysqldump command.

problem description

String [] str = {

        "mysqldump -h localhost -u root -p -t lailr_js_pay wx_sp > f:/test.sql"
        ,"root"
    };

Runtime.getRuntime (str) .exec executes the mysqldump command to generate the sql file
but if it is not used, it will report an error
Exception in thread "main" java.io.IOException: Cannot run program "mysqldump-h localhost-u root-p-t lailr_js_pay wx_sp > f:/wx1.sql": the CreateProcess error=2, system cannot find the specified file.

at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at com.test.Test.main(Test.java:18)

the Caused by: java.io.IOException: CreateProcess error=2, system cannot find the specified file.

at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 4 more

Apr.07,2021
The

error is obvious. If you can't find the mysqldump program, try writing an absolute path


running cmd, not mysqldump,
"mysqldump-h localhost-u root-p-t lailr_js_pay wx_sp > f:/test.sql"
this sentence is the parameter of cmd

Menu