Runing mysqldump from java code won't dump triggers
This is how i make mysql dumps from java
public static boolean mysqlDump(String destination){
File back=new File("tempsdfsdf.fdr");
Runtime rt = Runtime.getRuntime();
FileWriter fw=null;
try {
fw = new FileWriter(back);
}
catch (IOException ex) {
return false;
}
Process child;
try {
child = rt.exec("mysqldump -h"+generals.DATABASE_SERVER+" -u"+DATABASE_USER+" -p"+DATABASE_PASS+" --single-transaction --routines databasename -r"+destination);
InputStream in = child.getInputStream();
InputStreamReader xx = new InputStreamReader(in,"utf8");
char[] chars=new char[1024];
int ibyte=0;
while((ibyte=xx.read(chars))>0)
{
fw.write(chars);
}
fw.close();
Utils.deleteFile(back);
} catch (IOException ex) {
Logger.getLogger(FRMTestare.class.getName()).log(Level.SEVERE, null, ex);
return false;
}
return true;
}
The dump file is "destination",but i must simulate writing of InputStream() to a file to ensure that "destination" file is fully created when threat ends so that i can zip-it in another threat.Anyway this is not important!
My question is why when i run the command in cmd is dumping triggers but when i run the same command using Runtime.exec the triggers are not dumped .
Sorry ,the code i a mess but i lost all day changing it to dump triggers.
Thanks!
Copyright License: Author:「Cioban Andrei」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer. Link to:https://stackoverflow.com/questions/14237280/runing-mysqldump-from-java-code-wont-dump-triggers
About “Runing mysqldump from java code won't dump triggers” questions
This is how i make mysql dumps from java
public static boolean mysqlDump(String destination){
File back=new File("tempsdfsdf.fdr");
Runtime rt = Runtime.getRuntime();
FileWriter fw=null;
try {
...
|
I am writing a java app that needs to perform mysql dump, and I am using the runtime.exec, based in the when runtime.exec won't article. The code is below:
public int exectuteCommand(){
Runtim...
|
I want to backup mysql database with java.
And I want to launch mysqldump.exe independently on location of mysqldump.exe.
To launch mysqldump.exe I need to write full path to it :
String execute...
|
I successfully dumped data using Java runtime.exec. Now I want to handle exceptions like "mysqldump: Got error: 1045: Access denied for user 'errre'@'localhost' (using password: YES) when trying to
|
Ok, my Java application is not able to perform a mysqldump backup using the windows runtime enviroment. I have printout code for caught exceptions and I see no exceptions being thrown, looks fine o...
|
** 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/myf...
|
I'm a little curious about the behaviour of Runtime's exec() method when I run mysqldump. I'm running the following command:
mysqldump --user=root --hex-blob [database name] -r [path to sql file]
...
|
Try to backup mysql DB from Java application (IDE Netbeans) using the following command but can't seem to find the file even though I specified a path:
Runtime.getRuntime().exec("C:\\Program Files\\
|
I am using mysqldump like this:
Runtime.getRuntime().exec("mysqldump -u USERNAME -pPASSWORD DBNAME > /path/to/location/backup.sql");
in order to dump it into my local files, my java p...
|
I'm using MacOS Mojave and mysqldump is set to path in ~/.bash_profile
When using MacOS Terminal mysqldump is working.
Even with /bin/bash -c mysqldump it's working.
But when I try it with my Java
|
|
|