You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Paul Taylor <pa...@yahoo.com> on 2013/08/05 16:58:31 UTC
Fuseki and SDB
Hello,
I have been working with Fuseki and TDB for quite some time, however this weekend I have been trying to setup Fuseki with SDB. In particular, I have my application to open a connection to a local MySQL server and then to create a new database called "sdb_data". Then I create a Store object programmatically etc., a very brief snapshot of the Java code:
StoreDesc storeDesc = new StoreDesc(DEFAULT_LAYOUT, getDBType());
sdbStore = SDBFactory.connectStore(getSDBConnection(), storeDesc);
...
sdbStore.getTableFormatter().create();
I can verify that the SDB Store is created successfully because I can see that the database "sdb_data" is created with all the necessary tables inside to store RDF. Also, I can load/query an RDF-Graph in the store without any problems or exceptions. Note that for the purposes of my application I have many RDF-Graphs stored as Named Graphs, that means that I will never have any data to the default graph.
What I would like to do is to be able to connect to the SDB store just created and query the store with Sparql from Fuseki. The problem that I have is that when I ask a query to get a list of all the Named Graphs in the Store it returns an error in console. The strange thing is that if I run this query from the Java application programmatically it works, so it must be the setup of Fuseki using the .ttl file.
SELECT DISTINCT ?g
WHERE {
GRAPH ?g {
?s ?p ?o .
}
}
Error I am getting (Error 500: Server Error):
15:51:19 INFO [1] Query = SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o . } }
15:51:19 WARN [1] RC = 500 : null java.lang.NullPointerException
at com.hp.hpl.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.buildIterator(QueryIterGraph.java:175)
at com.hp.hpl.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.nextIterator(QueryIterGraph.java:155)
at com.hp.hpl.jena.sparql.engine.main.iterator.QueryIterGraph$QueryIterGraphInner.hasNextBinding(QueryIterGraph.java:118)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:81)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterConvert.hasNextBinding(QueryIterConvert.java:59)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterDistinctReduced.hasNextBinding(QueryIterDistinctReduced.java:54)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:40)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:112)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorWrapper.hasNextBinding(QueryIteratorWrapper.java:40)
Config setup:
The .ttl config file for Fuseki is as below, and just to provide as much info as I can, I am using:
jena-fuseki-0.2.7, jena-sdb-1.3.6.jar, jena-arq-2.10.1.jar, jena-tdb-0.10.1.jar, jena-core-2.10.1.jar, mysql-connector-java-5.1.22.jar.
Config file:
@prefix fuseki: <http://jena.apache.org/fuseki#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb: <http://jena.hpl.hp.com/2008/tdb#> .
@prefix sdb: <http://jena.hpl.hp.com/2007/sdb#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix : <#> .
##Setup a Fuseki server
[] rdf:type fuseki:Server ;
##Service to start
fuseki:services (
<#sdb_service>
) .
## SDB Store
[] ja:loadClass "com.hp.hpl.jena.sdb.SDB" .
sdb:DatasetStore rdfs:subClassOf ja:RDFDataset .
sdb:Model rdfs:subClassOf ja:Model .
<#sdb_service> rdf:type fuseki:Service ;
rdfs:label "SDB Service (RW)" ;
fuseki:name "metadata" ;
fuseki:serviceQuery "query" ;
fuseki:serviceQuery "sparql" ;
fuseki:serviceUpdate "update" ;
fuseki:serviceReadGraphStore "get" ;
fuseki:dataset <#dataset1> ;
.
<#dataset1> rdf:type sdb:DatasetStore ;
sdb:store <#store>;
.
##Connection to MySQL
<#store> rdf:type sdb:Store ;
rdfs:label "SDB Store" ;
sdb:layout "layout2" ;
sdb:engine "InnoDB" ;
sdb:connection
[ rdf:type sdb:SDBConnection ;
sdb:sdbType "MySQL" ;
sdb:sdbHost "localhost" ;
sdb:sdbName "sdb_data";
sdb:sdbUser "root";
sdb:sdbPassword "******";
sdb:driver "com.mysql.jdbc.Driver";
]
.
Many Thanks,
Paul