• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best way to extract the data from several tables into a file

 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have to extract the data from several tables (Oracle is the database)
and insert them into a file, in a specified format.

Each column will be allocated a certain size (filled with empty spaces if size is too big), and I will assign a line for each record extracted from the tables. There wont be any delimiter.
Example of such line:
column1 colum2column2 column4 etc

So i am looking for ways to do it in Java, of course.
Thanks in advance for your suggestions and ideas.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
377
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max,
First is to figure out your query. Do you want a join of the tables or each table separately or something else?

Once you have your query, loop through the result set and append data to the file. And once you start, you are welcome to post code here if you get stuck.

[edited to fix a typo]
[ August 17, 2005: Message edited by: Jeanne Boyarsky ]
 
Celinio Fernandes
Ranch Hand
Posts: 549
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, but i would like to find a more elegant way to do it.
I kind of had it with pure SQL statements now,
I was thinking about using Hibernate, but I think the learning curve is too important and I have a short time left to complete my task.

I am still open to new suggestions and ideas
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
377
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Max,
You still need to figure out what the query should be and loop through the result. You would only be able to replace the actual data access step in this way.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The hard part is figuring out column widths. I've done all of these at one time or another: derive the size from the column metadata, run through the data once to get the longest value for each column then run through again to report, use an external metadata file to specify column sizes. The external metadata gives you a chance to specify nice headings, too.

Any of those sound good? There are some open source packages that make columnar reports from result sets using only the column metadata. I made a primitive one of those that leaves a column blank if its the same value as the row before, making hierarchical data into an outline appearance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic