Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*NOTE: Creating Database Constraints*/
- String dbName = "biblioteca2";
- String dbUser = "root";
- String dbPass = "";
- /*NOTE: Creating Path Constraints for restoring*/
- String restorePath = jarDir + "\backup" + "\" + s;
- /*NOTE: Used to create a cmd command*/
- /*NOTE: Do not create a single large string, this will cause buffer locking, use string array*/
- String[] executeCmd = new String[]{"mysql", dbName, "-u" + dbUser, "-p" + dbPass, "-e", " source " + restorePath};
- /*NOTE: processComplete=0 if correctly executed, will contain other values if not*/
- Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
- int processComplete = runtimeProcess.waitFor();
- /*NOTE: processComplete=0 if correctly executed, will contain other values if not*/
- if (processComplete == 0) {
- JOptionPane.showMessageDialog(null, "Successfully restored from SQL : " + s);
- } else {
- JOptionPane.showMessageDialog(null, "Error at restoring");
- }
- } catch (Exception ex) {
- JOptionPane.showMessageDialog(null, "Error at Restoredbfromsql" + ex.getMessage());
- }
- }
Add Comment
Please, Sign In to add comment