java - How to Backup and Restore a MySQL Database using NetBeans? -
i'm developing software netbeans , i'm using mysql database server. i' planning use 2 buttons as, "backup database" , "restore database" respective functions. how accomplish these functions? , both functions, awesome if file chooser window used functions too. in advance! :)
what creating dump , saving it? , running when want restore?
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
edit:
well since dont know how achieve ill more specific.
mysqldumpl must run commandline pls read link:
http://docs.oracle.com/javase/7/docs/api/java/lang/runtime.html
your code should this:
string yourcommand = "mysqldump -h localhost -u [user] -p[database password] -c --add-drop-table --add-locks --all --quick --lock-tables [name of database] > sqldump.sql"; runtime.getruntime().exec(yourcommand);
after should have succefully saved file data of database
the last part of string "sqldump.sql"
name of file, can set own name file chooser, , replace name 1 user, google that.
well first done post code when have running , can tackle restoring of db
Comments
Post a Comment