Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is the solution I used, it works like on windows and linux the above suggestion to use apache commons exec:</p> <pre><code> String cmdline = "mysqldump"; DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); CommandLine commandLine = CommandLine.parse(cmdline); commandLine.addArgument("--host=" + dbhost); commandLine.addArgument("--port=" + dbport); commandLine.addArgument("--user=" + dbuser); commandLine.addArgument("--password=" + dbpass); commandLine.addArgument(database); Set keys = table.keySet(); for (Iterator i = keys.iterator(); i.hasNext();) { String key = (String) i.next(); String value = (String) table.get(key); commandLine.addArgument(value); } commandLine.addArgument("-r"); //outputFile might be a file on the server that can be downloaded //used apache file upload to download the files from the server commandLine.addArgument(outputFile); Executor executor = new DefaultExecutor(); executor.execute(commandLine, resultHandler); resultHandler.waitFor(); </code></pre> <p>And to restore the file to the server, Upload the file and here is the code to restore from a mysqldumpfile, this works if only mysql path has been set on the enviromental variables on windows but on linux it works as it is</p> <pre><code> String cmdline = "mysql"; DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler(); CommandLine commandLine = CommandLine.parse(cmdline); commandLine.addArgument("--user=" + dbuser); commandLine.addArgument("--password=" + dbpass); commandLine.addArgument("--force"); commandLine.addArgument("-v"); commandLine.addArgument("-e"); commandLine.addArgument("source"); commandLine.addArgument(backUpFile); commandLine.addArgument(database); Executor executor = new DefaultExecutor(); executor.execute(commandLine, resultHandler); resultHandler.waitFor(); </code></pre>
 

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