sparql - Querying an Open RDF Repository -
i trying query open rdf repository loaded turtle file. when selecting query - "select ?s { ?s ?p ?o } "; working fine when using little complex query not working. attaching code query portion -
private static void queryingrdf(repository repo) { try{ repositoryconnection con = repo.getconnection(); try{ string querystring = "select ?s { ?s uml:lineofbusiness cp:lobequities .}" ; tuplequery tuplequery = con.preparetuplequery(querylanguage.sparql, querystring); tuplequeryresult result = tuplequery.evaluate(); try { while(result.hasnext()){ bindingset bindingset = result.next(); value valueofx = bindingset.getvalue("s"); //value valueofy = bindingset.getvalue("p"); //value valueofz = bindingset.getvalue("o"); //system.out.println(valueofx + " " + valueofy + " " + valueofz); system.out.println(valueofx) ; } } { result.close(); } } finally{ con.close(); } } catch(openrdfexception e){ system.out.println("query error"); } }
this continuously getting exception section , throwing error - "query error". whats going wrong?
it looks don't define uml
or cp
prefixes. i'm looking statement in querystring:
prefix uml: <http://example.com/uml>
or call repositoryconnection::setnamespace this:
con.setnamespace("uml", "http://example.com/uml");
Comments
Post a Comment