Search in sources :

Example 11 with Store

use of org.apache.jena.sdb.Store in project jena by apache.

the class ExJdbcConnection method query.

public static void query(String queryString, StoreDesc storeDesc, Connection jdbcConnection) {
    Query query = QueryFactory.create(queryString);
    SDBConnection conn = new SDBConnection(jdbcConnection);
    Store store = StoreFactory.create(storeDesc, conn);
    Dataset ds = DatasetStore.create(store);
    QueryExecution qe = QueryExecutionFactory.create(query, ds);
    try {
        ResultSet rs = qe.execSelect();
        ResultSetFormatter.out(rs);
    } finally {
        qe.close();
    }
    // Does not close the JDBC connection.
    // Do not call : store.getConnection().close() , which does close the underlying connection.
    store.close();
}
Also used : SDBConnection(org.apache.jena.sdb.sql.SDBConnection) DatasetStore(org.apache.jena.sdb.store.DatasetStore) Store(org.apache.jena.sdb.Store)

Example 12 with Store

use of org.apache.jena.sdb.Store in project jena by apache.

the class SDBTestUtils method createInMemoryStore.

/** Create an HSQLDB-backed in-memory store for testing. */
public static Store createInMemoryStore() {
    SDBConnection conn = SDBFactory.createConnection("jdbc:hsqldb:mem:test", "sa", "");
    StoreDesc desc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.HSQLDB);
    Store store = SDBFactory.connectStore(conn, desc);
    store.getTableFormatter().create();
    store.getTableFormatter().truncate();
    return store;
}
Also used : StoreDesc(org.apache.jena.sdb.StoreDesc) SDBConnection(org.apache.jena.sdb.sql.SDBConnection) Store(org.apache.jena.sdb.Store)

Example 13 with Store

use of org.apache.jena.sdb.Store in project jena by apache.

the class TestAssembler method store_1.

@Test
public void store_1() {
    Store store = SDBFactory.connectStore(dir + "store.ttl");
    assertNotNull(store);
}
Also used : Store(org.apache.jena.sdb.Store) Test(org.junit.Test)

Example 14 with Store

use of org.apache.jena.sdb.Store in project jena by apache.

the class TestAssembler method pool_1.

@Test
public void pool_1() {
    // Connection
    Connection conn = SDBFactory.createSqlConnection(dir + "connection.ttl");
    // Store
    StoreDesc desc = StoreDesc.read(dir + "dataset2.ttl");
    Store store = SDBFactory.connectStore(conn, desc);
}
Also used : StoreDesc(org.apache.jena.sdb.StoreDesc) Connection(java.sql.Connection) Store(org.apache.jena.sdb.Store) Test(org.junit.Test)

Example 15 with Store

use of org.apache.jena.sdb.Store in project jena by apache.

the class TestAssembler method model_3.

@Test
public void model_3() {
    Model assem = FileManager.get().loadModel(dir + "graph-assembler.ttl");
    Resource xDft = assem.getResource("http://example/test#graphDft");
    Resource xNamed = assem.getResource("http://example/test#graphNamed");
    Store store = create(assem);
    Model model1 = (Model) Assembler.general.open(xDft);
    Model model2 = (Model) Assembler.general.open(xNamed);
    assertNotNull(model1 != model2);
}
Also used : Model(org.apache.jena.rdf.model.Model) Resource(org.apache.jena.rdf.model.Resource) Store(org.apache.jena.sdb.Store) Test(org.junit.Test)

Aggregations

Store (org.apache.jena.sdb.Store)18 Test (org.junit.Test)8 Model (org.apache.jena.rdf.model.Model)6 Resource (org.apache.jena.rdf.model.Resource)5 SDBConnection (org.apache.jena.sdb.sql.SDBConnection)5 Property (org.apache.jena.rdf.model.Property)4 StoreDesc (org.apache.jena.sdb.StoreDesc)4 Literal (org.apache.jena.rdf.model.Literal)3 DatasetStore (org.apache.jena.sdb.store.DatasetStore)3 TupleTable (org.apache.jena.sdb.store.TupleTable)2 Connection (java.sql.Connection)1 Graph (org.apache.jena.graph.Graph)1 Triple (org.apache.jena.graph.Triple)1 Dataset (org.apache.jena.query.Dataset)1 Statement (org.apache.jena.rdf.model.Statement)1 StmtIterator (org.apache.jena.rdf.model.StmtIterator)1 DatasetGraphSDB (org.apache.jena.sdb.store.DatasetGraphSDB)1 TableDesc (org.apache.jena.sdb.store.TableDesc)1 BeforeClass (org.junit.BeforeClass)1