• 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

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

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic