I want to query a database such as DB2 or Oracle8i and retreive the data (query results) in a XML file. Is it possible to do this? Should I store the query result to Java Bean(s) and then convert to XML?
Did you try using Oracle XDK ?. I think it has the necessary api to read Tables as XML and to insert XML into databases.
You will need to create a technet login for this.
alternatively if you don't want to be tied to Oracle api's use Jaxp, the Java xml API's or Xerxes api's from apache.
It depends on how complex your xml is
-one xml to one database table
- one xml from many database tables based on complex joins.
Now if you have the simple case you can write your own class which looks at the jdbc meta data and builds your xml for you.
The complex xml requires more work, so you are better off using some ready made packages for that. Things to look out..do they allow multilevel nesting. Oracle tools "do not" allow multilevel level nesting. You may also have to build some database object views.
Look at tools at apache or IBM developer works for some more insight into this.