• 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
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Data Base DUMP through Java

 
Ranch Hand
Posts: 60
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey
I want to create Dump file of data base in desktop application using Java. any one can help me about this....................
 
author & internet detective
Posts: 41967
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
Mark,
Do you know how to create a dump file using your database command line? If so, you could call that using Runtime.exec. If the database is on a separate machine than the desktop app, you'd also need to transfer the file.
 
Smart Bear Support
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We did something like this at my company, so I can help.

In any case you will need to go through all the tables in your application. This can either be all the tables in the database (via Connection.getMetaData().getTables()) or you might already have that list.

Then for each table you get the table's column meta-data (like name, type, is-null, etc.) which you also can get through Connection.getMetaData(). Then of course you "SELECT * FROM <tablename>" for each table.

Now the question is, what to do with that data?

If the goal is to create a dump file that can be executed directly against the database, then you literally write out statements like "DROP TABLE foo IF EXISTS" and "CREATE TABLE foo ( a, b, c )" and "INSERT INTO foo COLUMNS (...) VALUES (...)". That's fine, but it will probably work with only one type of table. Make sure you properly escape SQL string constants!

In my case the goal was to capture that data in XML form so that (a) we could restore it using other code we wrote, but also (b) any other tool could easily get access to the data. So you might consider that path too.
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic