Patrick Sahw
Patrick Sahw

Reputation: 1

convert java object from sql to xml

Is there a way or a function in java where java can create several xml documents for each customer that i am queering from a sql db?

PreparedStatement statement = connection.prepareStatement("SELECT (sqlstuff), (sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff) ,(sqlstuff) , (sqlstuff) , " + "(sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff) , (sqlstuff#), (sqlstuff#) OST00008 FROM filetype");

  ResultSet resultSet = statement.executeQuery();

Upvotes: 0

Views: 234

Answers (2)

Alex Marshall
Alex Marshall

Reputation: 10312

The easiest thing I've found was to use an ORM tool like Hibernate to map the objects into a database for me, and then use JAXB as well. I'd put the Hibernate annotations on the object's fields, and the XML annotations on the object's property getters, and I had to write almost no serialization code for either, only what was required to integrate with the two frameworks.

Upvotes: 0

Luca
Luca

Reputation: 4273

I suggest you this clean way:

  • Define your Customer class in java
  • Create a list of Customer from database rows
  • Convert your list of Customer in xml (using Jaxb for example)

Upvotes: 2

Related Questions