Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can test the below mentioned code for testing your mysqldump command output. There can be two main reasons to why the file is not creating, per my assumptions:-</p> <ol> <li>If using windows then the UAC permissions for the destined location can be the issue.</li> <li><p>You might be facing a syntax issue in the final mysqldump command generated to be executed by the java runtime. </p> <pre><code> //Process exec = Runtime.getRuntime().exec("C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysqldump "+fisier.getName()+" &gt; C:\\"+fisier.getName()+".sql;"); Process exec = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c","C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysqldump "+fisier.getName()+" &gt; C:\\"+fisier.getName()+".sql;"}); //Wait for the command to complete, and check if the exit value was 0 (success) if(exec.waitFor()==0) { //normally terminated, a way to read the output InputStream inputStream = exec.getInputStream(); byte[] buffer = new byte[inputStream.available()]; inputStream.read(buffer); String str = new String(buffer); System.out.println(str); } else { // abnormally terminated, there was some problem //a way to read the error during the execution of the command InputStream errorStream = exec.getErrorStream(); byte[] buffer = new byte[errorStream.available()]; errorStream.read(buffer); String str = new String(buffer); System.out.println(str); } </code></pre></li> </ol> <p>The redirection operator doesn't works when using <code>Process exec = Runtime.getRuntime().exec("C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysqldump "+fisier.getName()+" &gt; C:\\"+fisier.getName()+".sql;");</code></p> <p>It is becasue it does not invokes the command shell, so we cannot get the functionality of the redirection operator, in order to fix this we can execute a command prompt (cmd) followed by the mysqldump command, and it will work.</p> <p><code>Process exec = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c","C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin\\mysqldump "+fisier.getName()+" &gt; C:\\"+fisier.getName()+".sql;"});</code></p> <p>Here /c in the cmd.exe specify that execute the passed command and terminate the process. The actual command when executed by java runtime will become</p> <p>cmd.exe /c yourmysqldumpCommand</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload