It's not a secret anymore!*
The moose likes JDBC and the fly likes Access Database Dump Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Access Database Dump" Watch "Access Database Dump" New topic
Author

Access Database Dump

Charles Z Martin
Greenhorn

Joined: Jun 26, 2008
Posts: 9
Hi,

What I'm trying to accomplish is to dump an entire database table using a ResultSet.

The problem I'm facing is that the code should be generic for various tables such that no matter the amount of rows or columns it should just dump the entire table.

The dataset used is somewhat arbitrary.
Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
JDBC provides a vendor neutral way to access the database metadata, with which you can implement what you looking for. Check out this article for more info.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Use the built-in database export/import commands (or in the case of Access, copy the file). There's no such tool that will magically dump your database into a file format because database organization may be extremely complicated, especially the more your data is normalized.

For example, let says instead of US States in an address table, you have a StateId which refers to a record in a States table. How should such data be dumped? Should the Address print "New York City, 19" or "New York City, NY" which the ID resolved? You'd probably want the second one, but computer dumps aren't smart enough to handle such a case naturally. In other words, databases are structured and dumps (or flat files) are not, therefore the process of developing a 1-to-1 mapping is non-trivial unless you rely on built-in SQL commands


My Blog: Down Home Country Coding with Scott Selikoff
Charles Z Martin
Greenhorn

Joined: Jun 26, 2008
Posts: 9
I just implemented it myself, accessing the DB metadata gave me exactly what I wanted. luckily I did not really need to do anything with that data, just print it out in a user friendly manner.

Thanks to all who replied!
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

In that case what you were doing is really a SQL Projection, not a Dump (dump implies you want 100% of the data in a machine-readable format).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access Database Dump