• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Generating XML from SQL

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd like to generate an XML document from a SQL query. Is there a tool that do it easily? How should I do it?

1st step: retrieve the data
....
conn = getConnection();
query = "SELECT * FROM CLIENT";
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
....
2nd step: generate the XML file

I have no idea how to do it. I need your help.
Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Step 3: Profit!

Seriously, you would build up an in-memory DOM using the data you retrieve, then serialize it to the XML file. I am assuming that you are also planning on auto-generating the element names from database and column metadata?

In any case, this is much more of an XML issue than a JDBC one, so I'm going to transfer this over to the XML forum for further discussion.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic