I'm trying to restore a Mysql dump from a Java app. I'm using this code:
Runtime rt = Runtime.getRuntime();
try {
comando = "mysql -u root -ppass -e \"source " + path + "\\sql\\backup.sql\" legapelis" ;
Process proceso = rt.exec(comando);
System.out.println("ejecutando");
System.out.println(comando);
proceso.getInputStream().close();
proceso.getOutputStream().close();
proceso.getErrorStream().close();
completado = proceso.waitFor();
if (completado != 0) {
System.out.println("error");
addActionError(getText("backup.errcopia") + ": " + String.valueOf(completado));
consultarCopias();
return "error";
}
System.out.println("fin");
} catch (Exception e) {
addActionError(e.getLocalizedMessage());
consultarCopias();
return "error";
}
But the Mysql process that is opened by this code never ends. It hangs and if I kill it, the Mysql service stops working fine (I must restart it). I've tried a lot of codes: closing streams, reading it... but with the same result.
Any hint?
Excuse me if my English isn't so good.
Thank's
Ps: I've tried to add the -v option to the command to read it from inputstream. It start reading but then it hangs again (and it dosn't finish reading the output of the command: it stops suddenly)