title: An Error in my java database backup code
body: <pre><code>import java.io.File;
  import java.text.SimpleDateFormat;
  import java.util.Date;
  import javax.swing.JFileChooser;
  import javax.swing.JOptionPane;
  
  public class Backup extends javax.swing.JFrame {
  
      String path = null;
      String filename;
  
      public Backup() {
          initComponents();
  
          setLocationRelativeTo(null);
      }
  
      private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
          JFileChooser fc = new JFileChooser();
          fc.showOpenDialog(this);
          String date = new SimpleDateFormat("YYYY/MM/dd").format(new Date());
          try {
              File f = fc.getSelectedFile();
              path = f.getAbsolutePath();
              path = path.replace("\\", "/");
              path = path + " _ " + date + ".sql";
              jTextField5.setText(path);
          } catch (Exception e) {
              e.printStackTrace();
          }
  
          Process p;
          try {
              Runtime runtime = Runtime.getRuntime();
              p = runtime.exec("C:/Program Files/MySQL/MySQL Server5.1/bin/mysqldump.exe -u root -p123 --add-drop-database -B tsms -r" + path);
              int Processcomplete = p.waitFor();
              System.out.println(p);
              System.out.println("" + Processcomplete);
              if (Processcomplete == 0) {
                  JOptionPane.showMessageDialog(rootPane, "Database Backup Successfully");
              } else {
                  JOptionPane.showMessageDialog(rootPane, "Error");
              }
              jTextField5.setText(null);
              System.gc();
          } catch (Exception e) {
              e.printStackTrace();
              System.gc();
          }
      }
  }
  </code></pre>
  
  <p>I have developed a Java Swing Application with MySQL Server database and now I want to provide backup and restore option in my java swing application that is on click of a button. </p>
  
  <p>It should backup the database and restore the database any possibilities this is my backup code. But when I run this code always <code>(Processcomplete == 2)</code>  what is the error in this code?</p>