예제 #1
0
 /**
  * Run the parent teardown, and then remove all the freshly created graphs.
  *
  * @throws
  */
 public void tearDown() {
   super.tearDown();
   if (current != null) current.removeAll();
   try {
     connection.close();
   } catch (Exception e) {
     throw new JenaException(e);
   }
 }
  public static void main(String[] args) {
    try {
      String className = args[0];
      Class.forName(className);
      String DB_URL = args[1]; // URL of database
      String DB_NAME = args[2]; // DB name
      String DB_USER = args[3]; // database user id
      String DB_PASSWD = args[4]; // database password
      String DB = args[5]; // database type

      IDBConnection conn = new PagedDBConnection(DB_URL + DB_NAME, DB_USER, DB_PASSWD, DB);
      ModelMaker maker = ExtendedModelFactory.createPagedModelRDBMaker(conn);
      PagedModelRDB model = (PagedModelRDB) maker.createModel(args[6]);
      model.setDoDuplicateCheck(false);
      long startTime = System.currentTimeMillis();
      model.read(new FileInputStream(args[7]), null, "N3");
      long endTime = System.currentTimeMillis();
      System.out.println(
          "time to read in the model = " + (endTime - startTime) / 1000 + " seconds.\n");

      startTime = System.currentTimeMillis();
      long count = 0L;
      String queryString = " SELECT ?x ?y ?z " + " WHERE { ?x ?y ?z } ";
      QueryExecution qexec = QueryExecutionFactory.create(queryString, model);
      ResultSet rs = qexec.execSelect();
      while (rs.hasNext()) {
        count++;
        rs.nextSolution();
      }
      qexec.close();
      endTime = System.currentTimeMillis();
      System.out.println("count of found statements = " + count);
      System.out.println("time to query for results = " + (endTime - startTime) + " milliseconds.");

      conn.cleanDB();
      conn.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
 protected void tearDown() throws java.lang.Exception {
   model.close();
   model = null;
   conn.cleanDB();
   conn.close();
 }