Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean restoreDB(String dbName, String dbUserName, String dbPassword, String source) {
- String m_MySqlPath = "C:\\Program Files (x86)\\MySQL\\MySQL Server 5.7\\bin\\mysql";
- String[] executeCmd = new String[]{m_MySqlPath, "--user=" + dbUserName, "--password=" + dbPassword, dbName,"-e", " source "+source};
- Process runtimeProcess;
- try {
- runtimeProcess = Runtime.getRuntime().exec(executeCmd);
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement