i want to make a application that have some facilities like back up and restore database....
i make the application using java and netbeans as GUI and i use mysql as my database....
can you help me, hor to back up and restore mysql database in java language..
thx
Maximilian Xavier Stocker
Ranch Hand
Joined: Sep 20, 2005
Posts: 381
posted
0
Why do you want to do this? Is this a school project? Because there lots of tools already for this type of thing.
The best way to backup and restore a MySQL database would be the following.
1) Make your program that can run SQL script files (files full of SQL statements).
To backup
2) Dump the table definitions (as CREATE TABLE statements) and data (INSERT statements) into files.
3) Possibly zip resultant SQL files.
To restore
4) Possibly unzip SQL files.
5) execute SQL file
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
Originally posted by Maximilian Xavier Stocker: Why do you want to do this? Is this a school project? Because there lots of tools already for this type of thing.
i need it for my database project, where is can be have large record or database...
so i think, is it take time if i use max's method??? is you means that i must list all record in database (INSERT) and the table (TABLE)??? is it will take time for large database???
beside that, directory source is input by user.... can we get it automatically??? (in mySQL) example using registry like in Delphi??
Can you help me??
thanks you very much,...
Maximilian Xavier Stocker
Ranch Hand
Joined: Sep 20, 2005
Posts: 381
posted
0
It will take the time it takes. Even the utility I listed does the same thing I suggested so there is no other way then creating CREATE TABLE and INSERT statements and executing them to restore.
You cannot just copy the files. This is a bad idea unless you are prepared to stop the database. Because otherwise you won't know if the files are in a cohesive state. Actually it's a bad idea anyway because the table files could be corrupted and then you'd just be backing up a corrupted file.
Best way is to create the insert statements. You can write this yourself or use the tools provided. You can always execute other programs through Runtime.exec
Maximilian Xavier Stocker
Ranch Hand
Joined: Sep 20, 2005
Posts: 381
posted
0
But again there will be no shortcuts and if performance is an issue then I would suggest choosing a better (non-toy) database than MySQL. MySQL is a good example of you get what you pay for.