Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8503559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:47:20+00:00 2026-06-11T01:47:20+00:00

This is the code I created for exporting the database. The problem is, the

  • 0

This is the code I created for exporting the database. The problem is, the file is not exported, and the code shows no error message.

public boolean exportDatabase(String fromServer,
                              String FileName,
                              String FilePath,
                              int ExportOpions) {
  try {     
    String dbName ="NMSAzzist";
    String dbUser = "root";
    String dbPass ="root";  
    String dumbPath = "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\";
    String executeCmd = dumbPath+"mysqldump -u "+dbUser+ "-p"+dbPass+" "+dbName+ "-r "+FilePath+ "";
    Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
    int processComplete = runtimeProcess.waitFor();
    if (processComplete == 1) { // if values equal 1 process failed
      JOptionPane.showMessageDialog(null, "Backup Failed");//display message
    } else if (processComplete == 0) {
      JOptionPane.showMessageDialog(null, "\n Backup created Successfully..");
      // display message
    }
    return true;
  } catch (final Exception ex) {
    NmsLogger.writeErrorLog("Database Connection Failed ", ex.toString());
    NmsLogger.writeDebugLog(ex);
    return false;
  }

How can I export the database to a path specified in the variable FilePath in the name FileName? How can I solve the issue?

And BTW, can i use the following to import the same??

String[] executeCmd = new String[]{"mysql", databaseName, "-u" + userName, "-p" + password, "-e"  + FileName };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:47:21+00:00Added an answer on June 11, 2026 at 1:47 am

    You first try your executeCmd can run successfullly in db.
    In your executeCmd is syntax error. Your code left file name in execution command in

    String executeCmd = "/" + dumbPath + "mysqldump -u " + dbUser
                        + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
                        + FileName;
    

    Check the manual

    This works for me.

    public class exportDataBase {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            // TODO Auto-generated method stub
    
            exportDatabase("", "Sma_test.sql", "C:", 0);
    
        }
    
        public static boolean exportDatabase(String fromServer, String FileName,
                String FilePath, int ExportOpions) {
            try {
    
                String dbName = "dmsdev";
                String dbUser = "root";
                String dbPass = "root";
    
                String dumbPath = "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\";
    
                String executeCmd = "/" + dumbPath + "mysqldump -u " + dbUser
                        + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
                        + FileName;
    
                System.out.println(executeCmd);
                Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
                int processComplete = runtimeProcess.waitFor();
    
                System.out.println("processComplete: " + processComplete);
    
                if (processComplete == 1) {// if values equal 1 process failed
                    System.out.println("Backup failed");
                }
    
                else if (processComplete == 0) {
                    System.out.println("Backup Success");
    
                }
                return true;
            } catch (final Exception ex) {
                System.out.println("Connection failed");
                return false;
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created this Fiddle with this code: This is my problem I want
I have made this code to open a database(created in SQLite browser) stored in
This code does not upload the intended value to the database. I was expecting
I've created this code, it is supposed to use wordpress metabox functionality to save
I've created this code branch so that if the permalink settings do no match
I have an array created with this code: var widthRange = new Array(); widthRange[46]
I created a class under 'src' dir. I'm using this code to access the
I'm using Drupal 7. And i created a block and embed this code: $contents
I created an image fading slideshow reading this article . The code looks like
Created basic C++ DLL and exported names using Module Definition file (MyDLL.def). After compilation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.