This discussion is archived
5 Replies Latest reply: Sep 26, 2011 11:08 AM by alwu RSS

Using Jena for Data Upload

880207 Newbie
Currently Being Moderated
Hi,

I want to add triple data to my Model created in Oracle DB using Jena Code. There are millions of records to be added. Can anybody provide me sample code for Insert/update triple using Jena. I am using Oracle 11g release 2. I am looking for something like bulk upload.

Thanks and Regards,
Manish H
  • 1. Re: Using Jena for Data Upload
    alwu Pro
    Currently Being Moderated
    Hi,

    You can use either addInBulk or prepareBulk followed by a completeBulk method call.
    The following document has details

    https://students.kiv.zcu.cz/doc/oracle/appdev.112/e11828/sem_jena.htm#CBBJJJJB

    Be sure to dropApplicationTableIndex before you conduct the data loading. Also, if you have
    a multi-core balanced hardware system, you can run the data loading in parallel.

    Thanks,

    Zhe Wu
  • 2. Re: Using Jena for Data Upload
    880207 Newbie
    Currently Being Moderated
    Hi ,

    I have a Table - TB_1. Model - MD_1.

    I have triple Data in CSV/Excel File, below sample data is present in Column A, Column B and Column C of csv:

    http://my.com/contains     http://www.w3.org/2002/07/owl#inverseOf     http://my.com/containedBy
    http://my.com/MyBagXYZ     http://my.com/contains     http://my.com/item1
    http://my.com/MyBagXYZ     http://my.com/contains     http://my.com/item2
    http://my.com/MyBagXYZ     http://my.com/contains     http://my.com/itemn

    This Data is in Millions. I thought of using "INSERT DATA " clause of SparQL but as Data is in millions, i am looking for a better way.

    Can you help me how to read this CSV and Populate the model MD_1 using Jena and SparQL. Any Example would be of great help.
  • 3. Re: Using Jena for Data Upload
    alwu Pro
    Currently Being Moderated
    Hi MH,

    There are a few different approaches.

    You can use tools like http://www.mindswap.org/~anant/quidicrc/ or http://xlwrap.sourceforge.net/ to convert
    the CSV to RDF. Once you have the RDF, it is easy to bulk load it into Oracle.
    Note that I haven't used the aforementioned tools. So please sanity check the generated RDF to make sure
    conversion is 100% correct.

    Alternatively, you can read the CSV file yourself using a Java code.
    For each line, you generate a triple and then add the triple to an in-memory Jena model.
    After you are done with the whole file, addInBulk the whole Jena model to Oracle.

    Thanks,

    Zhe Wu
  • 4. Re: Using Jena for Data Upload
    880207 Newbie
    Currently Being Moderated
    Hi Zhe,

    Thanks for your answer. Can you provide any sample code how to use addInBulk () function. I will try creating in-memory model reading the csv using java and then want to load complete data in one time. Can you share any sample code for bulk loading of data.

    Thanks and Regards,
    Manish H
  • 5. Re: Using Jena for Data Upload
    alwu Pro
    Currently Being Moderated
    Hi MH,

    Section 7.10.3 of the following document has an example on addInBulk an in-memory Jena model to Oracle.
    https://students.kiv.zcu.cz/doc/oracle/appdev.112/e11828/sem_jena.htm#CBBJJJJB

    Thanks,

    Zhe Wu

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points