Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
123 views
in Technique[技术] by (71.8m points)

spring - the code is running successfully for the backup of mysql file in java

I am trying to get the backup of SQL file using the below status code, returning status code:0, when assumed as cmd it is executed successfully but otherwise there is some error. So the below code is running successfully but the output file is not generating don't know why.

Code: String filePath="/backup/"; String executeCmd = "mysqldump -u " + user + " " + dbname + " -r " + filePath+"backup.sql";

        //String executeCmd = "mysqldump -u " + user + " -p" + password + " " + dbname + " -r " + filePath+" backup.sql";

        Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
        status = runtimeProcess.waitFor();
        if (status == 0) {
            System.out.println("Backup taken successfully");
        } else {
            System.out.println("Could not take mysql backup");
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...