javajenablazegraph

Using Apache Jena with Blazegraph as Triplestore


For a project I have to use Apache Jena combined with Blazegraph as triplestore. But I have problems connecting Jena to Blazegraph by using RDFConnection.

RDFConnection conn = RDFConnectionFactory.connect(...)
conn.load("data.ttl") ;
QueryExecution qExec = conn.query("SELECT DISTINCT ?s { ?s ?p ?o }") ;
ResultSet rs = qExec.execSelect() ;
while(rs.hasNext()) {
    QuerySolution qs = rs.next() ;
    Resource subject = qs.getResource("s") ;
    System.out.println("Subject: "+subject) ;
}
qExec.close() ;
conn.close() ;

Blazegraph including its webinterface is running. This is the commandline output.

Welcome to the Blazegraph(tm) Database.

Go to http://192.168.222.1:9999/blazegraph/ to get started. WARN : MapgraphServletProxy.java:67: Running without GPU Acceleration. See >https://www.blazegraph.com/product/gpu-accelerated/.

I already read the examples at https://github.com/apache/jena/tree/master/jena-rdfconnection/src/main/java/org/apache/jena/rdfconnection/examples

RDFConnection conn = RDFConnectionFactory.connect("http://192.168.222.1:9999/blazegraph/");
conn.load("d:\\data.ttl") ;

leads to:

Exception in thread "main" org.apache.jena.atlas.web.HttpException: 404 - Not Found

At conn.load("d:\data.ttl") ;

Using "http://192.168.222.1:9999" as destination results in the same Exception.

Using "http://192.168.222.1/blazegraph" or "http://192.168.222.1"

lead to:

Exception in thread "main" org.apache.jena.atlas.web.HttpException: org.apache.http.conn.HttpHostConnectException: Connect to 192.168.222.1:80 [/192.168.222.1] failed: Connection refused: connect

at conn.load("data.ttl") ; also.

Could you please help me to find the correct way of connecting.


Solution

  • One solution for the problem

    String APIUrl = "http://192.168.222.1:9999/bigdata/sparql";
    RDFConnection conn = RDFConnectionFactory.connect(APIUrl,APIUrl,APIUrl);
    

    https://jena.apache.org/documentation/javadoc/rdfconnection/org/apache/jena/rdfconnection/RDFConnectionFactory.html#connect-java.lang.String-java.lang.String-java.lang.String-