| Author |
How to take MySql DB backup from java
|
Sumeet Chakraborty
Ranch Hand
Joined: Feb 05, 2009
Posts: 45
|
|
Hi all
I am trying to build a java utility which will enable me to take the backup of my MySql Database. I want the backup to be taken and dumped in a sql file in some location of my file system. Is there any way I could do it using Java code ? I searched a lot but didn't get any satisfying solution
Please help.
Thanks and Regards
Sumeet
|
 |
Fatih Keles
Ranch Hand
Joined: Sep 01, 2005
Posts: 182
|
|
Hi Sumeet,
Why do you need that? There is a command line utility called mysqldump for this purpose. Also you can find the following links useful from mysql manual.
http://dev.mysql.com/doc/refman/5.1/en/backup-methods.html
http://dev.mysql.com/doc/refman/5.0/en/copying-databases.html
Regards,
Fatih.
|
 |
Sumeet Chakraborty
Ranch Hand
Joined: Feb 05, 2009
Posts: 45
|
|
Thanks Fatih
But thats what my boss has asked me to do and thats what the requirement is ..so cant help
Please help
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
You will probably have to call it from Runtine.exec, and that is Java ( ), but make sure to read when runtime.exec() won't by Michael Daconta first.
|
 |
sarath j nair
Greenhorn
Joined: Nov 10, 2011
Posts: 11
|
|
Backup:
/******************************************************/
//Database Properties
/******************************************************/
/***********************************************************/
// Execute Shell Command
/***********************************************************/
Restore:
/******************************************************/
//Database Properties
/******************************************************/
/***********************************************************/
// Execute Shell Command
/***********************************************************/
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Sumeet Chakraborty wrote:Thanks Fatih
But thats what my boss has asked me to do and thats what the requirement is ..so cant help
Please help
Have you mentioned the command line utility to your boss? don't just presume they know everything and are being akward on purpose.
|
 |
arief ginanjar
Greenhorn
Joined: Jan 09, 2011
Posts: 5
|
|
Thank you sarath j nair for your sample, you make my day bright again...
|
 |
sarath j nair
Greenhorn
Joined: Nov 10, 2011
Posts: 11
|
|
|
You are always welcome Arief Ginanjar .....
|
 |
Isuru Ranawaka
Greenhorn
Joined: Jan 13, 2013
Posts: 2
|
|
Sumeet Chakraborty wrote:Hi all
I am trying to build a java utility which will enable me to take the backup of my MySql Database. I want the backup to be taken and dumped in a sql file in some location of my file system. Is there any way I could do it using Java code ? I searched a lot but didn't get any satisfying solution
Please help.
Thanks and Regards
Sumeet
Hi Sumeet, I created a solution myself. Please take a look and get if you think it will be useful.
It is not a complex solution, I used some SHOW CREATE and SELECT commands and parsed the strings.
I Tried to make it look alike to a backup you take from Navicat software.
Here is the code.
|
 |
 |
|
|
subject: How to take MySql DB backup from java
|
|
|