I make backups of the MySQL database in a Java application. Here is the code:
try { Runtime rt = Runtime.getRuntime(); String executeCmd = "mysqldump.exe -u " + dbUser + " -p " + dbPass; executeCmd += " --all-databases > " + savePath; System.out.println(executeCmd); Process proc = rt.exec(executeCmd); InputStream stderr = proc.getErrorStream(); InputStreamReader isr = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(isr); String line = null; System.out.println("<ERROR>"); while ( (line = br.readLine()) != null) System.out.println(line); System.out.println("</ERROR>"); int exitVal = proc.waitFor(); System.out.println("Process exitValue: " + exitVal); } catch (Throwable t) { t.printStackTrace(); } In response, I get exitValue: 1 . If you copy the output of System.out.pritln(executecmd); everything works fine in cmd. Can someone tell me what I'm doing wrong?
--verboseto the command to output something to the console - YuriySPb ♦ 4:44 pm