This tutorial shows you to backup your MySQL database using java (Windows PC) First you have to create a batch file, say bak.bat,
mysqldump -umysql-user -pmysql-password dbname > c:\backup.sql
java method
public boolean doBackup() {
Runtime rt;
try {
rt = Runtime.getRuntime();
Process run = rt.exec(bak.bat); // specify the correct path to batch file, eg:- c:\bak.bat
}
catch(Exception ex) {
//exception handlers
return false;
}
return true;
}
The method will write backup.sql file into C drive
No comments:
Post a Comment