It depends on many factors. If your XML is too large (> 1 GB or comparable to shared memory) then you should use SAX and I don't think there would be other solutions. If it's small (say, less than 100 MB), just load all the XML into the Document object using JAXP:
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); Document doc = parser.parse(source);
You probably have elements or attributes that appear in database columns. You can then query / attrs with XPath for simplicity and write them to the database. This is a one-time conversion, I recommend using a simple JDBC. Do not think about JPA or Hibernate, as this simply increases development time for a typical data conversion scenario.
source share