Vagelism
Vagelism

Reputation: 601

how to mysqldump on java?

I made my database in mySQL and I exported it in a file using mysqldump. Is there a way to make my program on JAVA to connect in mysql and create an empty database with the stracture I saved in the file, only if the above database is not allready exist to the server? Thank you!

Upvotes: 1

Views: 3170

Answers (1)

Manse
Manse

Reputation: 38147

Try something like :

Runtime.getRuntime().exec("mysql -u <username> -p<password> <youdbname> <  <youbackupfile>");

you will need to replace <username> with your username / <password> with your password / <yourdbname> with you database name / <yourbackupfile> with the file you used for backup

FAQ for MySQL Backup

Upvotes: 4

Related Questions