1 Reply Latest reply: Oct 18, 2011 5:47 PM by alwu-Oracle RSS

    Help Insert Data

    887107
      Hi i am student doing a project for my school and i trying to insert data
      i am inserting triples with jena adapter into my Oracle Database from a .nt file. 4 tables are being created FAMILY_NS, FAMILY_TPL, RDFB_FAMILY and RDFC_FAMILY. my data are in N-Triple format.i want to know why i can't view my data through sql-developer in my database.do i store those data or not?
      here is the code i use to insert data into my database
      import java.io.*;
      import com.hp.hpl.jena.query.*;
      import com.hp.hpl.jena.graph.*;
      import com.hp.hpl.jena.rdf.model.*;
      import com.hp.hpl.jena.util.*;
      import oracle.spatial.rdf.client.jena.*;
      public class Bulk {
      public static void main(String[] args) throws Exception
      {

      String szJdbcURL = "jdbc:oracle:thin:@192.168.2.3:1521:orcl";
      String szUser = "kostas";
      String szPasswd = "welcome";

      String szModelName = "Family";
      Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
      GraphOracleSem graph = new GraphOracleSem(oracle, szModelName);

      PrintStream psOut = System.out;

      String dirname = "C:\\users\\CoCo\\Desktop\\file";
      File fileDir = new File(dirname);
      String[] szAllFiles = fileDir.list();

      // loop through all the files in a directory
      for (int idx = 0; idx < szAllFiles.length; idx++) {
      String szIndFileName = dirname + File.separator + szAllFiles[idx];
      psOut.println("process to [ID = " + idx + " ] file " + szIndFileName);
      psOut.flush();

      try {
      // Model model = FileManager.get().loadModel("C:\\users\\CoCo\\Desktop\\file\\example.nt");
      InputStream is = new FileInputStream(szIndFileName);
      graph.getBulkUpdateHandler().prepareBulk(
      is, // input stream
      "http://www.recshop.fake/cd", // base URI
      "N-TRIPLE", // data file type: can be RDF/XML, N-TRIPLE, etc.
      null, // tablespace
      null, // flags
      null, // listener
      null // staging table name.
      );
      is.close();
      }

      catch (Throwable t) {
      psOut.println("Hit exception " + t.getMessage());
      }
      }
      }
      }

      Edited by: CoCo on Oct 18, 2011 6:14 AM

      Edited by: CoCo on Oct 18, 2011 6:15 AM