use of org.apache.jena.sdb.Store in project jena by apache.
the class sdbtuple method execPrint.
private void execPrint(String tableName) {
Store store = getStore();
TupleTable table = null;
if (tableName.equalsIgnoreCase(store.getNodeTableDesc().getTableName())) {
// A hack.
// Need to chage SQLBridge to work on Node tables directly (no special build of value getters)
TableDesc desc = new TableDesc(tableName, store.getNodeTableDesc().getNodeRefColName());
table = new TupleTable(store, desc);
} else
table = new TupleTable(store, tableName);
divider();
table.dump();
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class TestConnection method connection_1.
@Test
public void connection_1() {
SDBConnection conn1 = SDBFactory.createConnection(conn);
Store store1 = StoreFactory.create(storeDesc, conn1);
// Reset
store1.getTableFormatter().format();
SDBConnection conn2 = SDBFactory.createConnection(conn);
Store store2 = StoreFactory.create(storeDesc, conn2);
Model model1 = SDBFactory.connectDefaultModel(store1);
Model model2 = SDBFactory.connectDefaultModel(store2);
Resource s = model1.createResource();
Property p = model1.createProperty("http://example/p");
// These are autocommit so two stores should be OK (but not a good design paradigm)
model1.add(s, p, "model1");
model2.add(s, p, "model2");
assertEquals(2, model1.size());
assertEquals(2, model2.size());
assertTrue(model1.isIsomorphicWith(model2));
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class TestConnectionPooled method reuseJDBCConection.
@Test
public void reuseJDBCConection() {
Triple t1 = SSE.parseTriple("(:x1 :p :z)");
Triple t2 = SSE.parseTriple("(:x2 :p :z)");
boolean explicitTransactions = false;
// Make store.
{
SDBConnection sConn1 = SDBConnectionFactory.create(conn);
Store store1 = StoreFactory.create(sConn1, store.getLayoutType(), store.getDatabaseType());
if (explicitTransactions)
store1.getConnection().getTransactionHandler().begin();
Graph graph1 = SDBFactory.connectDefaultGraph(store1);
graph1.add(t1);
assertTrue(graph1.contains(t1));
if (explicitTransactions) {
store1.getConnection().getTransactionHandler().commit();
assertTrue(graph1.contains(t1));
}
//store1.close() ;
}
// Mythically return conn to the pool.
// Get from pool
// i.e. same connection. Make a store around it
{
SDBConnection sConn2 = SDBConnectionFactory.create(conn);
Store store2 = StoreFactory.create(sConn2, store.getLayoutType(), store.getDatabaseType());
if (explicitTransactions)
store2.getConnection().getTransactionHandler().begin();
Graph graph2 = SDBFactory.connectDefaultGraph(store2);
assertTrue(graph2.contains(t1));
graph2.add(t2);
assertTrue(graph2.contains(t2));
if (explicitTransactions)
store2.getConnection().getTransactionHandler().commit();
//store2.close() ;
}
System.exit(0);
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class StoreList method testStore.
public static Store testStore(StoreDesc desc) {
Store store = StoreFactory.create(desc);
// HSQL and H2 (in memory) need formatting
// Better would be to know in memory/on disk
// Relies on StoreDesc getting the label correctly (SDBConnectionFactory)
String jdbcURL = store.getConnection().getJdbcURL();
boolean isInMem = (jdbcURL == null ? false : jdbcURL.contains(":mem:"));
if (formatStores || inMem(store))
store.getTableFormatter().create();
return store;
}
use of org.apache.jena.sdb.Store in project jena by apache.
the class TestAssembler method model_5.
@Test
public void model_5() {
Model assem = FileManager.get().loadModel(dir + "graph-assembler.ttl");
Resource xDft = assem.getResource("http://example/test#graphDft");
Store store = create(assem);
// Default graph: Check they are connected to the same place in the store
Model model2 = (Model) Assembler.general.open(xDft);
Model model3 = (Model) Assembler.general.open(xDft);
Resource s = model2.createResource();
Property p = model2.createProperty("http://example/p");
// Check two models connected to the same graph
Literal o2 = model2.createLiteral("xyz");
model2.add(s, p, o2);
assertTrue(model3.contains(s, p, o2));
}
Aggregations