• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read data from an XML file and store it into database(MySQL) ?  RSS feed

 
Raj Shharma
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to get data from xml file and store it into MySQL Database. I am thinking of using SAX Parser for parsing the data but I am not sure of how to store data efficiently into database, I am thinking of few technologies like JDBC, Hibernate but I wanted to ask about what would be the efficient way of doing it ?

Note: Here programming language is Java.

Thanks.
 
Paul Clapham
Sheriff
Posts: 22205
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your question is "How do I store data into a database?" then that really isn't an XML question. It makes no difference that you happened to get the data from an XML document. This is a pretty vague and unfocused question but let's try it in the JDBC forum.
 
Scott Selikoff
author
Bartender
Posts: 4085
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see this question come up every few months. In short, there's no simple answer. Data in XML may be highly structured or highly unstructured and mapping it to a set of database tables is non-trivial. The issue of what fields to normalization (put in their own table) is cumbersome at best. For example, if you have a list of addresses, do you pull all the states out and put them in a state table, replacing the state in addresses with a StateId?

I recommend designing a database structure that fits your application and requirements, then building a tool that maps between the XML and the database. Trying to base the database straight off the XML is bound to give you headaches in the long run.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!