Examples of SailConnection


Examples of org.openrdf.sail.SailConnection

  {
    MySqlStore sail = new MySqlStore("sesame_test");
    sail.setUser("sesame");
    sail.setPassword("opensesame");
    sail.initialize();
    SailConnection conn = sail.getConnection();
    try {
      conn.begin();
      conn.removeStatements(null, null, null);
      conn.clearNamespaces();
      conn.commit();
    }
    finally {
      conn.close();
    }
    return sail;
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

    URIFactory factory = store.getURIFactory();
    URI foo = factory.createURI("http://www.foo.example/foo");
    URI bar = factory.createURI("http://www.foo.example/bar");

    SailConnection con = store.getConnection();
    con.addStatement(foo, RDF.TYPE, bar);

    TupleQueryModel query = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL,
        "SELECT X, P, Y FROM {X} P {Y}", null);

    Cursor<? extends BindingSet> iter = con.evaluate(query,
        EmptyBindingSet.getInstance(), false);

    BindingSet bindingSet = iter.next();

    assertEquals(bindingSet.getValue("X"), foo);
    assertEquals(bindingSet.getValue("P"), RDF.TYPE);
    assertEquals(bindingSet.getValue("Y"), bar);
    iter.close();
    con.close();

    store.shutDown();

    store = new MemoryStore(dataDir);
    store.initialize();

    factory = store.getURIFactory();
    foo = factory.createURI("http://www.foo.example/foo");
    bar = factory.createURI("http://www.foo.example/bar");

    con = store.getConnection();

    iter = con.evaluate(query, EmptyBindingSet.getInstance(), false);

    bindingSet = iter.next();

    assertEquals(bindingSet.getValue("X"), foo);
    assertEquals(bindingSet.getValue("P"), RDF.TYPE);
    assertEquals(bindingSet.getValue("Y"), bar);

    iter.close();
    con.addStatement(bar, RDF.TYPE, foo);
    con.close();
   
    store.shutDown();
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

      sb.append('a');
    }

    Literal longLiteral = store.getLiteralFactory().createLiteral(sb.toString());

    SailConnection con = store.getConnection();
    con.addStatement(foo, RDF.TYPE, longLiteral);
    con.close();
    store.shutDown();

    store = new MemoryStore(dataDir);
    store.initialize();

    con = store.getConnection();

    Cursor<? extends Statement> iter = con.getStatements(foo, RDF.TYPE, null,
        false);
    assertTrue(iter.next() != null);
    iter.close();

    con.close();
    store.shutDown();   
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

  {
    if (shutDownInProgress) {
      throw new IllegalStateException("shut down in progress");
    }

    SailConnection con = getConnectionInternal();
    con = tracker.track(con);
    con = wrapConnection(con);
    return con;
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

      // Forcefully close any connections that are still open
      Iterator<Map.Entry<SailConnection, Throwable>> iter = activeConnections.entrySet().iterator();
      while (iter.hasNext()) {
        Map.Entry<SailConnection, Throwable> entry = iter.next();
        SailConnection con = entry.getKey();
        Throwable stackTrace = entry.getValue();

        iter.remove();

        if (stackTrace == null) {
          logger.warn(
              "Closing active connection due to shut down; consider setting the {} system property",
              SailUtil.DEBUG_PROP);
        }
        else {
          logger.warn("Closing active connection due to shut down, connection was acquired in",
              stackTrace);
        }

        try {
          con.close();
        }
        catch (StoreException e) {
          logger.error("Failed to close connection", e);
        }
      }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

  @Override
  protected SailConnection getConnectionInternal()
    throws StoreException
  {
    SailConnection con = factory.createConnection();
    con = new SynchronizedSailConnection(con);
    con = new AutoCommitSailConnection(con);
    return con;
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

  }

  protected Cursor<? extends BindingSet> evaluate(QueryModel query)
    throws StoreException
  {
    SailConnection sailCon = getConnection().getSailConnection();

    Cursor<? extends BindingSet> bindingsIter;
    bindingsIter = sailCon.evaluate(query, getBindings(), getIncludeInferred());

    if (maxQueryTime > 0) {
      bindingsIter = new QueryInterruptCursor(bindingsIter, 1000L * maxQueryTime);
    }

 
View Full Code Here

Examples of org.openrdf.sail.SailConnection

  {
    PgSqlStore sail = new PgSqlStore("sesame_test");
    sail.setUser("sesame");
    sail.setPassword("opensesame");
    sail.initialize();
    SailConnection conn = sail.getConnection();
    try {
      conn.begin();
      conn.removeStatements(null, null, null);
      conn.clearNamespaces();
      conn.commit();
    }
    finally {
      conn.close();
    }
    return sail;
  }
View Full Code Here

Examples of org.openrdf.sail.SailConnection

    public void testAll() throws Exception {
        URI planet = new URIImpl("http://example.org/terms/planet");
        URI gasGiant = new URIImpl("http://example.org/terms/gasGiant");
        URI narrower = new URIImpl("http://www.w3.org/2004/02/skos/core#narrower");

        SailConnection sc = sail.getConnection();
        try {
            sc.begin();
            sc.addStatement(planet, RDFS.LABEL, new LiteralImpl("planet", "en"));
            sc.addStatement(gasGiant, RDFS.LABEL, new LiteralImpl("gas giant", "en"));
            sc.addStatement(planet, narrower, gasGiant);
            sc.commit();
        } finally {
            sc.close();
        }

        Vertex p = sailGraph.getVertex(planet.stringValue());

        FramedGraph<SailGraph> framedGraph = new FramedGraphFactory().create(sailGraph);
View Full Code Here

Examples of org.openrdf.sail.SailConnection

        }
        _abbreviatedItems = true;
       
        getRepository();
       
        SailConnection sc = null;
        try {
            sc = _sail.getConnection();
        } catch (SailException e) {
            _logger.error("Failed to open sail connection in order to compute cached information", e);
        }
       
        if (sc != null) {
            try {
                CloseableIteration<? extends Statement, SailException> i;
               
                try {
                    i = sc.getStatements(null, RDF.TYPE, null, true);
                } catch (SailException e) {
                    _logger.error("Failed to get all statements in order to abbreviate items", e);
                    return;
                }
               
                try {
                    while (i.hasNext()) {
                        Statement s = i.next();
                        Resource r = s.getSubject();
                        if (r instanceof URI) {
                            getItemId((URI) r, sc);
                        }
                    }
                } catch (SailException e) {
                    _logger.warn("Failed to iterate through statements", e);
                } finally {
                    try {
                        i.close();
                    } catch (SailException e) {
                        _logger.warn("Failed to close statement iterator", e);
                    }
                }
            } finally {
                try {
                    sc.close();
                } catch (SailException e) {
                    _logger.warn("Failed to close sail connection", e);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.