Reputation: 1422
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
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
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