In my desktop application whenever execute the code to backup my database from java application the app goes on waiting state may be for password , which we have to enter while backing up from command line. But i've provided the username and password of database in the code. Why is it going on waiting state. please help how can i do this. My execution code is:
public boolean backupDB(String dbName, String dbUserName, String dbPassword) {
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec("C://xampp//mysql//bin//mysqldump -u"+ dbUserName+" -p "+dbPassword+" dbName+" > D://backup.sql");
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;
}