1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public class Main {
public static void main(String[] args) {
String path = "F:/sauvegarde.sql";
String username = "root";
String password = "";
String dbname = "personne";
String executeCmd = "C:\\wamp\\bin\\mysql\\mysql5.6.17\\bin\\mysqldump.exe -u " + username + " -p "+password +" "+ dbname + " --add-drop-table -B --databases" + " -r " + path;;
try {
String[] commande = {"cmd.exe", "/C",executeCmd };
Process p = Runtime.getRuntime().exec(commande);
int indiceprocess = p.waitFor();
if(indiceprocess = 0){
System.out.println("exportation effectuee avec succes");
}
else{
System.out.println("exportation no effectuee");
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} |
Partager