<docbook><section><title>VirtJenaSPARQLExample3</title><para> </para>
<title> Virtuoso Jena Provider - SPARQL Example 3</title> Virtuoso Jena Provider - SPARQL Example 3
<programlisting>import java.util.*;

import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;

import virtuoso.jena.driver.*;

public class VirtuosoSPARQLExample3
{
    public static void main(String[] args)
    {
	String url;

	if(args.length == 0)
	    url = &quot;jdbc:virtuoso://localhost:1111&quot;;
	else
	    url = args[0];

	Node foo1 = Node.createURI(&quot;http://example.org/#foo1&quot;);
	Node bar1 = Node.createURI(&quot;http://example.org/#bar1&quot;);
	Node baz1 = Node.createURI(&quot;http://example.org/#baz1&quot;);

	Node foo2 = Node.createURI(&quot;http://example.org/#foo2&quot;);
	Node bar2 = Node.createURI(&quot;http://example.org/#bar2&quot;);
	Node baz2 = Node.createURI(&quot;http://example.org/#baz2&quot;);

	Node foo3 = Node.createURI(&quot;http://example.org/#foo3&quot;);
	Node bar3 = Node.createURI(&quot;http://example.org/#bar3&quot;);
	Node baz3 = Node.createURI(&quot;http://example.org/#baz3&quot;);

	List &lt;Triple&gt; triples = new ArrayList &lt;Triple&gt; ();

	VirtGraph graph = new VirtGraph (&quot;Example3&quot;, url, &quot;dba&quot;, &quot;dba&quot;);

	graph.clear ();

	System.out.println(&quot;graph.isEmpty() = &quot; + graph.isEmpty());
	System.out.println(&quot;Add 3 triples to graph &lt;Example3&gt;.&quot;);

	graph.add(new Triple(foo1, bar1, baz1));
	graph.add(new Triple(foo2, bar2, baz2));
	graph.add(new Triple(foo3, bar3, baz3));

	System.out.println(&quot;graph.isEmpty() = &quot; + graph.isEmpty());
	System.out.println(&quot;graph.getCount() = &quot; + graph.getCount());

	triples.add(new Triple(foo1, bar1, baz1));
	triples.add(new Triple(foo2, bar2, baz2));

	graph.isEmpty();

	System.out.println(&quot;Remove 2 triples from graph &lt;Example3&gt;&quot;);
	graph.remove(triples);
	System.out.println(&quot;graph.getCount() = &quot; + graph.getCount());
	System.out.println(&quot;Please check result with isql tool.&quot;);

	/* EXPECTED RESULT:

SQL&gt; sparql select ?s ?p ?o from &lt;Example3&gt; where {?s ?p ?o};
s                                                    p                                                             o
VARCHAR                                    VARCHAR                                              VARCHAR
_______________________________________________________________________________

http://example.org/#foo3              http://example.org/#bar3                         http://example.org/#baz3

1 Rows. -- 26 msec.
SQL&gt;

*/

	}
}
</programlisting><para> </para>
</section></docbook>