Search in sources :

Example 11 with SDBConnection

use of org.apache.jena.sdb.sql.SDBConnection 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 SDBConnection

use of org.apache.jena.sdb.sql.SDBConnection 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 SDBConnection

use of org.apache.jena.sdb.sql.SDBConnection in project jena by apache.

the class StoreCreator method getHashSQLServer.

public static Store getHashSQLServer() {
    if (sdbssh == null) {
        JDBC.loadDriverSQLServer();
        SDBConnection sdb = SDBFactory.createConnection(MSSQL_url + "test2-hash", MSSQL_user, MSSQL_password);
        StoreDesc desc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.SQLServer);
        sdbssh = new StoreTriplesNodesHashSQLServer(sdb, desc);
        sdbssh.getTableFormatter().create();
    } else
        sdbssh.getTableFormatter().truncate();
    return sdbssh;
}
Also used : StoreDesc(org.apache.jena.sdb.StoreDesc) SDBConnection(org.apache.jena.sdb.sql.SDBConnection)

Example 14 with SDBConnection

use of org.apache.jena.sdb.sql.SDBConnection in project jena by apache.

the class StoreCreator method getHashOracle.

public static Store getHashOracle() {
    if (sdboh == null) {
        JDBC.loadDriverOracle();
        // "jena", "swara"
        String url = JDBC.makeURL("oracle:thin", "localhost:1521", "XE");
        SDBConnection sdb = new SDBConnection(url, "test2-hash", "test2-hash");
        StoreDesc desc = new StoreDesc(LayoutType.LayoutTripleNodesHash, DatabaseType.Oracle);
        sdboh = new StoreTriplesNodesHashOracle(sdb, desc);
        sdboh.getTableFormatter().create();
    } else
        sdboh.getTableFormatter().truncate();
    return sdboh;
}
Also used : StoreDesc(org.apache.jena.sdb.StoreDesc) SDBConnection(org.apache.jena.sdb.sql.SDBConnection)

Example 15 with SDBConnection

use of org.apache.jena.sdb.sql.SDBConnection in project jena by apache.

the class StoreCreator method getIndexDerby.

public static Store getIndexDerby() {
    if (sdbdi == null) {
        JDBC.loadDriverDerby();
        String url = JDBC.makeURL("derby", "localhost", "DB/test2-index");
        SDBConnection sdb = new SDBConnection(url, null, null);
        StoreDesc desc = new StoreDesc(LayoutType.LayoutTripleNodesIndex, DatabaseType.Derby);
        sdbdi = new StoreTriplesNodesIndexDerby(sdb, desc);
        sdbdi.getTableFormatter().create();
    } else
        sdbdi.getTableFormatter().truncate();
    return sdbdi;
}
Also used : StoreDesc(org.apache.jena.sdb.StoreDesc) SDBConnection(org.apache.jena.sdb.sql.SDBConnection)

Aggregations

SDBConnection (org.apache.jena.sdb.sql.SDBConnection)21 StoreDesc (org.apache.jena.sdb.StoreDesc)18 Store (org.apache.jena.sdb.Store)5 DatasetStore (org.apache.jena.sdb.store.DatasetStore)2 Test (org.junit.Test)2 Graph (org.apache.jena.graph.Graph)1 Triple (org.apache.jena.graph.Triple)1 Model (org.apache.jena.rdf.model.Model)1 Property (org.apache.jena.rdf.model.Property)1 Resource (org.apache.jena.rdf.model.Resource)1