I have a database named "Clients" and i want to get only "contacts" table without taking other database tables as a backup. I want to do this in my java swing application and please help me with this problem.
Asked
Active
Viewed 418 times
1
-
1this has nothing at all to do with Swing. Swing is just a framework that can be used to provide the user with a GUI. Select the table to backup, store it in memory, write it to another destination (file, other table, ... ) – Stultuske Dec 05 '18 at 11:15
-
Here is a post (and answer) about [MySQL: Backing up single table](https://stackoverflow.com/questions/6682916/how-to-take-backup-of-a-single-table-in-a-mysql-database). I guess rest of the Swing GUI can take care of the application. Link to [Java's Swing Tutorials](https://docs.oracle.com/javase/tutorial/uiswing/index.html). I think you should Google little bit and look for specific questions and answers. – prasad_ Dec 05 '18 at 11:27
1 Answers
1
Here is a way it can be done.
In the Swing application there can be a function for backup database. This function can be triggered from a menu option or a button. Let us take a button click as an example.
Create a JButton
with name "Backup Database" in the application.
Add an ActionListener
to the button. The actionPerformed
method has the function's logic: This opens a JDialog
with a status JTextArea
, JButton
s to select a target folder/file name of the backup, start the process, close the dialog, etc. The status area can display the selected folder, the output file name, success/error messages, etc. The process:
- Select the destination folder
- May be, there is an option to select the table name to be backed up
- Build the target filename (probably has a timestamp included in the filename)
- Click the start button: Run a SQL DDL using JDBC's
Statement
object'sexecuteUpdate
method. This runs the SQL to create the backup and updates the status area with the backup file name -or- in case of an exception displays an appropriate message (and followup actions).
The dialog can look like this:
Also, see these posts:

prasad_
- 12,755
- 2
- 24
- 36