Does anyone know good XML library for Java which I can use to write data extracted from database into XML format?
+3
A:
Usually, those tools are already provided by the database itself. Check the "Export" section somewhere in their documentation. A more detailed answer can't be given since the DB vendor is unmentioned.
Regardless, if you insist in using Java for this (which may however be performance/memory hogging with large data), then you may find a Javabean-to-XML serializer useful, for example JAXB, XStream or XMLBeans.
BalusC
2010-05-03 14:18:14
+1; the OP would be well-served to not reinvent this particular wheel. :-)
BlairHippo
2010-05-03 14:20:08
Thanks , but the data I need to extract from database is not from a single table , but multiple and with custom formatting.
yogsma
2010-05-03 14:30:27
You should mention JAXB it comes with java 1.6
Justin
2010-05-03 14:31:39
@BalusC - I understand. There is much more to this ..harmonization of data won't happen in SQL , I need to do that in my code before transforming into XML.
yogsma
2010-05-03 14:48:09
@yogsma: aren't you undervaluing SQL? Joins? Functions? Procedures? The average DB is undoubtely much more efficient in this job. In Java you would need to get hold of all the data in memory and then preferably need 2~5 times more free space in the memory than the data actually large is, else you will face constantly `OutOfMemoryErrors`. I would still consult some SQL Ninja (or ask here) if it is really, *really* not possible in pure SQL. Just to be sure.
BalusC
2010-05-03 14:54:47
@BalusC - Thanks, let me figure this out little bit , else I will ask the question for sure.
yogsma
2010-05-03 14:57:02
+2
A:
JAXB all you need to do is annotate a class and you can marshal it to XML. Works well with JPA entities / other ORMs as well.
Justin
2010-05-03 14:18:31
+1, also the MOXy implmentation of JAXB has a number of extensions for dealing with JPA entities http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
Blaise Doughan
2010-08-12 16:01:14