I'm trying to take a backup of a mysql database using the following code.
public boolean backupDB() {
String executeCmd = "mysqldump -u root -p 1234 --add-drop-database -B test -r D:\\backup\\aaa.sql";
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if (processComplete == 0) {
System.out.println("Backup created successfully");
return true;
} else {
System.out.println("Could not create the backup");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}
But it always gives me this error:
CreateProcess error=2, The system cannot find the file specified
How can I resolve this? Thanks