1
Good afternoon, I have a cmd that correctly backs up my database, but when running in java it does not open the cmd in the expected way, it follows the code:
package sistemaMiriam.backup;
import java.io.IOException;
public class MySQLBackup {
public static void main(String[] args){
String comando = "C:\\xampp\\mysql\\bin\\mysqldump sistema_miriam -u root -p ";
try {
Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL "+comando);
} catch (IOException e) {
e.printStackTrace();
}
}
}
If I put C:\\xampp\\mysql\\bin\\mysqldump sistema_miriam -u root -p >nomeParaArquivo.sql
he executes the >nomeParaArquivo.sql
as if it were a table and not create a file with the data from the bd
rundll32 SHELL32.DLL,ShellExec_RunDLL
andcomando
are two different commands right? Try this http://answall.com/a/57076/3635, there explains the use of&
, perhaps theProcessBuilder
can solve your problem– Guilherme Nascimento
I tried to change, according to an example I saw on the net,
Runtime.getRuntime().exec("mysqldump --opt --user=root --password sistema_miriam > my_db.sql");
but says that the path was not found, some suggestion?– Matheus Lopes
Matheus this means that mysql is not configured in the PATH environment variable, once I have a time I formulate a response.
– Guilherme Nascimento
Okay, thank you very much
– Matheus Lopes
I edited the question, I had an evolution, some suggestion?
– Matheus Lopes