I use mysqldump to get mysql database backup.it's work fine when i try it on dos prompt.
like this..
>mysqldump -u uname -ppassword databaseName>C:/backup.sql
this will create backup.sql file.
then i try this in java
Sure, empty catch block is the bad point to find error.
Also, you are running "C:/Programme.exe"
with arguments
1. Files/MySQL/MySQL
2. Server
3. 5.0/bin/mysqldump
etc.
have you any executables with such name?
Shashika Thiran
Greenhorn
Joined: Jan 22, 2009
Posts: 24
posted
0
I have printStacktrace() in catch block and file path is fine...it's soething else i think
Dmitry Mamonov
Greenhorn
Joined: Dec 24, 2008
Posts: 28
posted
0
Sasika, would you like to trick us posting code which has no relation to you real problem?
with you posted code we have next:
rt.exec("C:/Programme Files/MySQL/MySQL Server 5.0/bin/mysqldump -u uname -ppassword databaseName>C:/backup.sql");
Yes, Runtime.exec(String[]) is much better than Runtime.exec(String). It saves you from all the trouble about paths containing spaces and parameters needing to be quoted.
Also be sure to handle the input/error/output stream of the child process. This is described in detail in the article "When Runtime.exec() won't" by Daconta. Nobody should use Runtime.exec without reading that.
Sasika Thiranga wrote:C:/Programme Files/MySQL/MySQL Server 5.0/bin/mysqldump -u uname -ppassword databaseName>C:/backup.sql
1) shouldn't there be a space between -p and password?
2) file redirection like this (using > C:/backup.sql) is handled by the shell (cmd.exe), it is not part of the application. To do the same in Java you would need to get the process' output (through getInputStream()) and copy its contents to a FileOutputStream("C:/backup.sql") manually. This would also solve half of the problems that the article Ulf mentioned is about. (You'll still need to clear getErrorStream().)
Have you read my previous post? I told you how you could handle ">" in Java. "<" is similar: call the Process object's getOutputStream(), create an InputStream, and copy the data.
Shashika Thiran
Greenhorn
Joined: Jan 22, 2009
Posts: 24
posted
0
now i write code like this..
but it not restore my backup.please help me with this code.
Thanks.