I have developed a Java application and it's in last stage.
The problem is that I cannot execute the mysqldump with Runtime.getRuntime().exec().
try {
String[] command = new String[] {
"cmd.exe",
"/c",
"mysqldump --host=" + host + " --user=" + dbuser + " --password=" + dbpass + " " + dbname + " > " + filename
};
Process runtimeProcess = Runtime.getRuntime().exec(command);
int ProcessComplete = runtimeProcess.waitFor();
if (ProcessComplete == 0) {
JOptionPane.showMessageDialog(null, "Database backup has been done successfully");
}
else {
JOptionPane.showMessageDialog(null, "Database backup was unsuccessfull");
JOptionPane.showMessageDialog(null, command);
}
}
catch (IOException | InterruptedException exc) {
Logger.getLogger(Backup.class.getName()).log(Level.SEVERE, null, exc);
}
Can anyone help me with this?