Last active
December 16, 2015 02:49
-
-
Save harschware/5365165 to your computer and use it in GitHub Desktop.
Code for connecting Sesame to a SPARQL endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package harschware.drivers; | |
| import org.openrdf.model.Statement; | |
| import org.openrdf.model.URI; | |
| import org.openrdf.model.ValueFactory; | |
| import org.openrdf.repository.RepositoryConnection; | |
| import org.openrdf.repository.RepositoryException; | |
| import org.openrdf.repository.RepositoryResult; | |
| import org.openrdf.repository.sparql.SPARQLRepository; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| public class SesameClientDriver { | |
| public static void main(String[] args) throws RepositoryException { | |
| SPARQLRepository sr = new SPARQLRepository("http://localhost:3030/dataset/sparql"); | |
| sr.initialize(); | |
| RepositoryConnection conn = sr.getConnection(); | |
| ValueFactory vf = conn.getValueFactory(); | |
| try { | |
| URI uri = vf.createURI("http://dbpedia.org/ontology/ProgrammingLanguage"); | |
| RepositoryResult<Statement> rs = conn.getStatements(uri, null, null, false); | |
| while(rs.hasNext() ) { | |
| Statement s = rs.next(); | |
| System.out.println(s); | |
| } | |
| rs.close(); | |
| } | |
| finally { | |
| conn.close(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment