• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Take backup from MYSQL through java

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Please someone help me --How to take backup automatically from the database(MYSQL) after certains number of records from java GUI.
When the record count exceeds certain count then the records should move from the table to backup.

Regards,
Prathana
 
author & internet detective
Posts: 41995
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Prathana,
Do you know the command line to do a backup from mySql? If so, you could call this from Java using Runtime.exec()
 
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MySQL has a deprecated function for backing up a single table.

BACKUP TABLE tbl_name [, tbl_name] ... TO '/path/to/backup/directory'

But keep in mind... this is a very poor way to back up your data in a relational database.

You would be better served by determining a way to handle time variancy in your table's structure
 
prathana balaji
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot.
jeanne,I know the command line that is given in sql command line
mysqldump -a -u root -p dbname > dbname.sql
How can I call that in java using Runtime.exec()?
Can you please explain me ...

Thanks in advance

Regards
Parthana
 
Sheriff
Posts: 22813
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by prathana balaji:
mysqldump -a -u root -p dbname > dbname.sql
How can I call that in java using Runtime.exec()?



[ November 30, 2007: Message edited by: Rob Prime ]
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone, I created a solution myself. Please take a look and get if you think it will be useful.

This is in reply to this from Prarthana balaji.

prathana balaji wrote:Hi all,
Please someone help me --How to take backup automatically from the database(MYSQL) after certains number of records from java GUI.
When the record count exceeds certain count then the records should move from the table to backup.

Regards,
Prathana



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.


Full usable 8.java file can be found here. http://isuru.diyatha.com/java-db-dump/
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic