Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems running SPARQL queries with Oracle Jena Adaptor

712796Jul 20 2009 — edited Sep 23 2009
Hello,

I am trying to run the SPARQL queries using the Jena adaptor.

I'm using Jena 2.6.0 and all the relevant jars (Pellet and ojdbc5) and running on Oracle 11gR1.

I am running theexample code provided with the Jena Adaptor:
public void testOrderBy(String jdbcUrl, String user,
String password, String modelName,
PrintStream psOut)
throws SQLException, IOException
{
Oracle oracle = new Oracle(jdbcUrl, user, password);
GraphOracleSem graph = new GraphOracleSem(oracle, modelName);
ModelOracleSem model = new ModelOracleSem(graph);

Node sub = Node.createURI("http://sub/a3");
Node pred = Node.createURI("http://pred/p1-a3");
Node obj = Node.createLiteral("8888");
graph.add(Triple.create(sub, pred, obj));

sub = Node.createURI("http://sub/a2");
pred = Node.createURI("http://pred/p2-a2");
graph.add(Triple.create(sub, pred, obj));

sub = Node.createURI("http://sub/a4");
pred = Node.createURI("http://pred/p3-a4");
graph.add(Triple.create(sub, pred, obj));

String queryString = " SELECT ?s ?p ?o "
+ " WHERE { ?s ?p ?o . } "
+ " ORDER BY ?s ";

psOut.println("testOrderBy: query 1");
runQuery(QueryFactory.create(queryString), model, psOut);


String queryString2 = " SELECT ?s ?p ?o "
+ " WHERE { ?s ?p ?o . } "
+ " ORDER BY DESC (?p) ";

psOut.println("testOrderBy: query 2");
runQuery(QueryFactory.create(queryString2), model, psOut);

graph.close();
oracle.dispose();
}

I'm getting the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: com.hp.hpl.jena.graph.query.Query.getTriples()Lcom/hp/hpl/jena/graph/query/NamedTripleBunches;
at oracle.spatial.rdf.client.jena.OracleSemQueryPlan.getStatements(OracleSemQueryPlan.java:363)
at oracle.spatial.rdf.client.jena.OracleSemQueryPlan.executeBindings(OracleSemQueryPlan.java:182)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterBlockTriplesQH$StagePattern.<init>(QueryIterBlockTriplesQH.java:90)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterBlockTriplesQH.nextStage(QueryIterBlockTriplesQH.java:56)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.makeNextStage(QueryIterRepeatApply.java:87)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply.hasNextBinding(QueryIterRepeatApply.java:49)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIteratorBase.hasNext(QueryIteratorBase.java:71)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterSort.sort(QueryIterSort.java:44)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterSort.<init>(QueryIterSort.java:36)
at com.hp.hpl.jena.sparql.engine.iterator.QueryIterSort.<init>(QueryIterSort.java:31)
at com.hp.hpl.jena.sparql.engine.main.OpCompiler.compile(OpCompiler.java:292)
at com.hp.hpl.jena.sparql.engine.main.CompilerDispatch.visit(CompilerDispatch.java:142)
at com.hp.hpl.jena.sparql.algebra.op.OpOrder.visit(OpOrder.java:28)
at com.hp.hpl.jena.sparql.engine.main.CompilerDispatch.compile(CompilerDispatch.java:33)
at com.hp.hpl.jena.sparql.engine.main.OpCompiler.compileOp(OpCompiler.java:71)
at com.hp.hpl.jena.sparql.engine.main.OpCompiler.compile(OpCompiler.java:298)
at com.hp.hpl.jena.sparql.engine.main.CompilerDispatch.visit(CompilerDispatch.java:149)
at com.hp.hpl.jena.sparql.algebra.op.OpProject.visit(OpProject.java:47)
at com.hp.hpl.jena.sparql.engine.main.CompilerDispatch.compile(CompilerDispatch.java:33)
at com.hp.hpl.jena.sparql.engine.main.OpCompiler.compileOp(OpCompiler.java:71)
at com.hp.hpl.jena.sparql.engine.main.OpCompiler.compile(OpCompiler.java:49)
at com.hp.hpl.jena.sparql.engine.main.QueryEngineMain.eval(QueryEngineMain.java:43)
at com.hp.hpl.jena.sparql.engine.QueryEngineBase.createPlan(QueryEngineBase.java:81)
at com.hp.hpl.jena.sparql.engine.QueryEngineBase.getPlan(QueryEngineBase.java:70)
at com.hp.hpl.jena.sparql.engine.main.QueryEngineMain$1.create(QueryEngineMain.java:59)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.getPlan(QueryExecutionBase.java:262)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.startQueryIterator(QueryExecutionBase.java:239)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execResultSet(QueryExecutionBase.java:244)
at com.hp.hpl.jena.sparql.engine.QueryExecutionBase.execSelect(QueryExecutionBase.java:77)
at example.Examples.runQuery(Examples.java:1748)
at example.Examples.testOrderBy(Examples.java:1035)
at example.Test.main(Test.java:23)

Does any one has any idea what is the problem? What am I guilty of?

Doron,
This post has been answered by alwu-Oracle on Jul 20 2009
Jump to Answer

Comments

alwu-Oracle
Answer
There has been some interface changes with Jena itself.
Consequently the Oracle Jena Adaptor 2.0 does not work with Jena 2.5.7 or Jena 2.6.0. Please try 2.5.6.
We are working on a new version of the Jena Adaptor and this restriction has been lifted.

Cheers,

Zhe Wu
Marked as Answer by 712796 · Sep 27 2020
696067
Any updates as to when Oracle Jena Adapter will be compatible with Jena 2.6.0? I really want to use some of the property-path functions in ARQ 2.8.0.

Edited by: alexi on Sep 9, 2009 1:28 AM - And please don't make me use GLEEN ;)
alwu-Oracle
Next version of Jena Adaptor will be 2.6.0 compatible.

Property path is a very interesting/powerful feature. To help us optimize, could you please list the typical property path examples you'd like to adopt for your application?

Thanks,

Zhe Wu
696067
Hi Zhe,
After some thought and a few conversations with colleagues, I definitely think the most important thing to optimize property paths for is transitivity. Basically people want to be able to efficiently do something like this:

Select:
sbe:Cluster sbe:contains+ ?node
?node rdf:type sbe:NodeType

or the reverse (in the same amount of time):

Select:
?node rdf:type sbe:NodeType
sbe:Cluster sbe:contains+ ?node

Of course the property sbe:contains can be made into a transitive property but then we can't explore the graph level by level (i.e. 1 edge/predicate at a time) since ARQ has no simple way to turn transitivity off. Thus we are forced to create a new 'transitive' version of contains called sbe:tcontains which we then auto-generate (i.e. during graph.performInference()) via a user_rulebase entry (i.e. custom rule). It would be much more convenient if we could tell the rulebase to precompute transitivity for certain properties but only travel the transitive links if explicitly stated in the query.

For example:
EXECUTE sem_apis.create_entailment(... , OptimizeTransitivityPath(sbe:contains) , ...);
or:
Node containsNode = ...
Attachment.createInstance(... ,OptimizeTransitivityPath(containsNode) ,...);

-Alexi
alwu-Oracle
Hi Alexi,

Those two usages of property paths are in the plan.

Cheers,

Zhe Wu
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 21 2009
Added on Jul 20 2009
5 comments
4,135 views