<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gareth Jones &#187; graph</title>
	<atom:link href="http://blog.garethj.com/tag/graph/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.garethj.com</link>
	<description></description>
	<lastBuildDate>Tue, 07 Sep 2010 17:37:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Using Jena as a SPARQL endpoint</title>
		<link>http://blog.garethj.com/2010/01/using-jena-as-a-sparql-endpoint/</link>
		<comments>http://blog.garethj.com/2010/01/using-jena-as-a-sparql-endpoint/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 15:27:30 +0000</pubDate>
		<dc:creator>gareth</dc:creator>
				<category><![CDATA[techy solutions]]></category>
		<category><![CDATA[arc]]></category>
		<category><![CDATA[arq]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[endpoint]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[jena]]></category>
		<category><![CDATA[joseki]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[named]]></category>
		<category><![CDATA[optional]]></category>
		<category><![CDATA[owl]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[semantic web]]></category>
		<category><![CDATA[sparql]]></category>
		<category><![CDATA[sparql-update]]></category>
		<category><![CDATA[sparul]]></category>
		<category><![CDATA[specification]]></category>
		<category><![CDATA[store]]></category>
		<category><![CDATA[triple]]></category>
		<category><![CDATA[triple store]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.garethj.com/?p=154</guid>
		<description><![CDATA[I&#8217;ve been involved in a few projects at work over the last couple of years that have made use of Semantic Web technologies (triple stores, RDF, OWL, SPARQL etc). For most of these I&#8217;ve made of ARC, a really great &#8230; <a href="http://blog.garethj.com/2010/01/using-jena-as-a-sparql-endpoint/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been involved in a few projects at work over the last couple of years that have made use of Semantic Web technologies (triple stores, RDF, OWL, SPARQL etc). For most of these I&#8217;ve made of <a href="http://arc.semsol.org/">ARC</a>, a really great PHP library by <a href="http://twitter.com/bengee">Ben Nowack</a> for interacting with RDF and triple stores. As great as ARC is, it does have a few drawbacks such as being limited to MySQL triple stores, <a href="http://arc.semsol.org/community/arc-dev/archives/2009/12/PM-GA.20091215173026.C408A.2.1D@semsol.com">some issues with OPTIONAL queries</a> and it <a href="http://www.w3.org/2001/sw/DataAccess/tests/implementations">doesn&#8217;t entirely support the SPARQL specification</a>.</p>
<p>For these reasons and for general flexibility, my current project wanted to be able to easily swap the underlying triple store from ARC to Jena as needed so I needed to investigate how to expose a Jena triple store as a SPARQL endpoint. After working this out, I now really really appreciate <a href="http://arc.semsol.org/docs/v2/endpoint">how easy ARC makes this</a>.</p>
<p>Jena doesn&#8217;t appear to ship with the ability to expose the <a href="http://jena.sourceforge.net/ARQ/">ARQ SPARQL processor</a> as a SPARQL endpoint and hence you need to make use of a separate piece of software called <a href="http://www.joseki.org/">Joseki</a>. The following is the list of things I needed to do to get this working in my environment. Note that your setup may have different requirements and also I may have completely misunderstood the best way of doing this!</p>
<ol>
<li>Setup a database to use as your triple store and get a JDBC driver so Joseki can interact with it from Java</li>
<li><a href="http://joseki.sourceforge.net/download.html">Download</a> and extract Joseki</li>
<li>Add the JDBC driver to the Joseki classpath (e.g. for Windows by adding the following line to <code>bin\joseki_path.bat</code>: <code>set CP=%CP%;C:\my_jdbc_driver\my_jdbc_driver.jar</code>)</li>
<li>Add the following to joseki-config.ttl:
<pre>
 <#myProjectUpdate>
   rdf:type            joseki:Service ;
   rdfs:label          "My Project SPARQL/Update" ;
   joseki:serviceRef   "sparql/myproject/update" ;
   joseki:dataset      <#myProject> ;
   joseki:processor    joseki:ProcessorSPARQLUpdate .

 <#myProjectRead>
   rdf:type            joseki:Service ;
   rdfs:label          "SPARQL" ;
   joseki:serviceRef   "sparql/myproject/read" ;
   joseki:dataset      <#myProject> ;
   joseki:processor    joseki:ProcessorSPARQL_FixedDS .

 <#myProject>
   rdf:type            ja:RDFDataset ;
   rdfs:label          "My Project" ;
   ja:defaultGraph     <#myProjectDB> .

 <#myProjectDB>
   rdf:type            ja:RDBModel ;
   ja:connection       [
                         ja:dbType "MySQL" ;
                         ja:dbURL          <jdbc:mysql://localhost/myproject-database> ;
                         ja:dbUser         "myproject-database-username" ;
                         ja:dbPassword     "myproject-database-password" ;
                         ja:dbClass        "com.mysql.jdbc.Driver"
                        ] ;
   ja:reificationMode    ja:minimal ;
   ja:modelName        "DEFAULT" .
    </pre>
</li>
<li>Set the <code>JOSEKIROOT</code> environment variable to the location you extracted Joskei</li>
<li>Run Joseki (from it&#8217;s directory) by executing <code>bin/rdfserver.bat</code></li>
</ol>
<p>Note that I wanted to be able to make use of <a href="http://www.w3.org/Submission/SPARQL-Update/">SPARUL</a> to update data using the SPARQL endpoint. In ARC I can use <a href="http://arc.semsol.org/docs/v2/sparql+">SPARQL+</a> (which is effectively the same for my purposes) on the same endpoint as normal SPARQL queries. For Joseki however, I needed to expose two different endpoints, one for standard SPARQL queries and one for updating.</p>
<p>The one thing I haven&#8217;t yet worked out how to do it to be able to use named graphs in my Jena triple store when inserting data. I discovered that the SPARUL update specification <a href="http://www.w3.org/Submission/SPARQL-Update/#t415">requires you to create the graph first</a> (unlike ARC&#8217;s SPARQL+) but executing e.g. <code>CREATE GRAPH &lt;http://mygraph/&gt;</code> seems to fail silently as any following <code>INSERT INTO &lt;http://mygraph/&gt;</code> statement fails saying that the graph doesn&#8217;t exist. Something to keep investigating. It may be something to do with support for the different types of Jena store (RDB, SDB, TDB, etc) which I don&#8217;t fully understand yet (I think my instructions above are using RDB which appears to be old but I couldn&#8217;t get TDB or SDB working at all).</p>
<p>So all in all I&#8217;m pleased to have worked out how to set this up but I will most certainly continue to use ARC where possible as Jena environments seem unnecessarily complex (although this might simply be because it tends to support the W3 specifications fully!).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.garethj.com/2010/01/using-jena-as-a-sparql-endpoint/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
