Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>Backup: /******************************************************/ //Database Properties /******************************************************/ String dbName = “dbName”; String dbUser = “dbUser”; String dbPass = “dbPass”; /***********************************************************/ // Execute Shell Command /***********************************************************/ String executeCmd = “”; executeCmd = “mysqldump -u “+dbUser+” -p”+dbPass+” “+dbName+” -r backup.sql”; } Process runtimeProcess =Runtime.getRuntime().exec(executeCmd); int processComplete = runtimeProcess.waitFor(); if(processComplete == 0){ out.println(“Backup taken successfully”); } else { out.println(“Could not take mysql backup”); } Restore: /******************************************************/ //Database Properties /******************************************************/ String dbName = “dbName”; String dbUser = “dbUser”; String dbPass = “dbPass”; /***********************************************************/ // Execute Shell Command /***********************************************************/ String executeCmd = “”; executeCmd = new String[]{“/bin/sh”, “-c”, “mysql -u” + dbUser+ ” -p”+dbPass+” ” + dbName+ ” &lt; backup.sql” }; } Process runtimeProcess =Runtime.getRuntime().exec(executeCmd); int processComplete = runtimeProcess.waitFor(); if(processComplete == 0){ out.println(“success”); } else { out.println(“restore failure”); } </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