Forum Stats

  • 3,838,710 Users
  • 2,262,394 Discussions


How to create a JAVA consumer to update an oracle database

Keith8 Member Posts: 1
edited Jul 30, 2018 12:12PM in Java Programming

I will be provided a stream of data that is encoded in XML looking something like this:

<transaction tid='00000000000000001121' ts='2013-06-02 22:14:36.000000' ops='4' commitTs='2013-06-02 22:14:36.000000'>

<operation table='TEST.CUSTOMER' type='INSERT' ts='2013-06-02 22:14:36.000000' pos='00000000000000001121' numCols='4'>

<col name='CODE' index='0'>



<col name='NAME' index='1'>

   <after><![CDATA[JOHNNY APPLEBY]]></after>


<col name='CITY' index='2'>



<col name='STATE' index='3'>





How do set up a consumer to accept this and insert this into an Oracle database?

Sorry I know this is very basic JAVA as I have never done this.




  • dvohra21
    dvohra21 Member Posts: 14,618 Gold Crown
    edited Jul 29, 2018 11:41PM

    Java is not needed if the complete XML document is to be stored as such.  Store the complete XML document in XMType column. Refer "Oracle XML DB: Choosing the Best XMLType Storage Option for Your Use Case"

    Java is needed if the XML is to be parsed and element values stored in different columns. Use a SAX parser. Refer tutorial "Parsing an XML File Using SAX".

  • OrhanCemalDuru
    OrhanCemalDuru Member Posts: 6
    edited Jul 30, 2018 12:12PM

    Using a model-view-controller approach, you need an object for each table in the database that maps to it. You could create an instance of the object that maps to TEST.CUSTOMER table, store the values according to the xml, which could be done using libraries manipulating tags, and then store it in the database. There are tools that create objects which map database tables automatically.


    See Java DOM API for XMLType

This discussion has been closed.