Gapchoos
Gapchoos

Reputation: 1422

Error in Mysql export

This is the code I tried for exporting the database.

    //MysqlPath = "C:\Program Files\MySQL\MySQL Server 5.1\bin\"
    String executeCmd = "\"" +Mysqlpath+ " mysqldump -u " + dbUser
                + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
                + FileName;

    System.out.println(executeCmd);
    Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);

I get the following error :

***Cannot run program """C:\Program": CreateProcess error=87, The parameter is incorrect***

How can I solve this?

Upvotes: 1

Views: 118

Answers (2)

Stephan
Stephan

Reputation: 43033

Try this :

File fMysqlPath = new File("C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\");
String executeCmd = "mysqldump -u " + dbUser
            + " -p" + dbPass + " " + dbName + " -r " + FilePath + "\\"
            + FileName;

System.out.println(executeCmd);
Process runtimeProcess = Runtime.getRuntime().exec(executeCmd, null, fMysqlPath);

Java 1.4.2

Upvotes: 1

thar45
thar45

Reputation: 3560

I hope this could help you , run dump command from java code

  Runtime.getRuntime().exec("mysqldump -u username -p password  databasename > /../.. datadump.sql");

Correct me if 'm wrong

Upvotes: 2

Related Questions