its my code for restoring mysql databse using java command.
when i debug the code it get stuck at runtimeProcess.waitFor();
can any one provide solution for this problem?
public static boolean restoreDB(String dbUserName, String dbPassword,String dbName, String path) {
String command ="mysql -u"+dbUserName+" -p"+dbPassword+" "+dbName+" < \""+path+"\"";
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec(command);
int processComplete = runtimeProcess.waitFor();
if (processComplete == 0) {
System.out.println("Backup restored successfully");
return true;
} else {
System.out.println("Could not restore the backup");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}