Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- CodeSource codeSource = Settings.class.getProtectionDomain().getCodeSource();
- File jarFile = new File(codeSource.getLocation().toURI().getPath());
- String jarDir = jarFile.getParentFile().getPath();
- String dbName = "tuktukan";
- String dbUser = "root";
- String dbPass = "";
- String folderPath = jarDir + "\backup";
- File f1 = new File(folderPath);
- f1.mkdir();
- String savePath = """ + jarDir + "\backup\" + "backup.sql"";
- String executeCmd = "C:/xampp/mysql/bin/mysqldump -u" + dbUser + " -p" + dbPass + " --databases " + dbName + " -r " + savePath;
- Process process = null;
- Runtime runtime = Runtime.getRuntime();
- System.out.println("HI");
- process = runtime.exec(executeCmd);
- System.out.println(executeCmd);
- int processComplete = process.waitFor();
- if (processComplete == 0) {
- JOptionPane.showMessageDialog(null, "Backup Successful");
- } else {
- JOptionPane.showMessageDialog(null, "Backup Failed");
- }
- } catch (URISyntaxException | IOException | InterruptedException ex) {
- JOptionPane.showMessageDialog(null, "Error at Backuprestore" + ex.getMessage());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement