--The following command works fine when run directly on terminal
mysqldump -uabc -pabc1234 --compact --no-create-info -w \"fieldname != 'A'\" dbname tablename -hhostaddress --result-file=/tmp/myfile.txt
--But when it is executed using Runtime() method then it does not produce the output in the destination file.
String s="mysqldump -uabc -pabc1234 --compact --no-create-info -w \"fieldname != 'A'\" dbname tablename -hhostaddress --result-file=/tmp/myfile.txt";
Runtime.getRuntime().exec(s);
(--say abc is the username and abc1234 the password)
The same problem occurs if redirection to the destination file ( > ) is usedinstead of --result-file option.
What shall i do to execute it from within a java program ?
Running mysqldump from java in linux
Page 1 of 11 Replies - 143 Views - Last Post: 28 December 2012 - 06:14 AM
Replies To: Running mysqldump from java in linux
#2
Re: Running mysqldump from java in linux
Posted 28 December 2012 - 06:14 AM
Have a look at http://technojeeves..../52-runtimeexec
The more complex the command, the more likely you are to get better results using the String[] form of Runtime.exec. I would also be consistent with the parameter formats, using the longer style as more readable. One of your trickier ones would be something like
command[5] = "--where=\"fieldname != 'A'\"";
An easier way would be to place the command that works into a script and Runtime.exec that script
The more complex the command, the more likely you are to get better results using the String[] form of Runtime.exec. I would also be consistent with the parameter formats, using the longer style as more readable. One of your trickier ones would be something like
command[5] = "--where=\"fieldname != 'A'\"";
An easier way would be to place the command that works into a script and Runtime.exec that script
This post has been edited by g00se: 28 December 2012 - 01:26 PM
Reason for edit:: Easier
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|