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

import com.hp.hpl.jena.query.*;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.graph.Triple;

import virtuoso.jena.driver.*;

public class VirtuosoSPARQLExample7
{

    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 triples1 = new ArrayList();
	triples1.add(new Triple(foo1, bar1, baz1));
	triples1.add(new Triple(foo2, bar2, baz2));
	triples1.add(new Triple(foo3, bar3, baz3));

	List triples2 = new ArrayList();
	triples2.add(new Triple(foo1, bar1, baz1));
	triples2.add(new Triple(foo2, bar2, baz2));

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

	graph.clear ();

	System.out.println(&quot;graph.isEmpty() = &quot; + graph.isEmpty());
	System.out.println(&quot;Add List with 3 triples to graph &lt;Example7&gt; via BulkUpdateHandler.&quot;);

	graph.getBulkUpdateHandler().add(triples1);

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

	ExtendedIterator iter = graph.find(Node.ANY, Node.ANY, Node.ANY);
	System.out.println (&quot;\ngraph.find(Node.ANY, Node.ANY, Node.ANY) \nResult:&quot;);
	for ( ; iter.hasNext() ; )
	    System.out.println ((Triple) iter.next());


	System.out.println(&quot;\n\nDelete List of 2 triples from graph &lt;Example7&gt; via BulkUpdateHandler.&quot;);

	graph.getBulkUpdateHandler().delete(triples2);

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

	iter = graph.find(Node.ANY, Node.ANY, Node.ANY);
	System.out.println (&quot;\ngraph.find(Node.ANY, Node.ANY, Node.ANY) \nResult:&quot;);
	for ( ; iter.hasNext() ; )
	    System.out.println ((Triple) iter.next());

	graph.clear ();
	System.out.println(&quot;\nCLEAR graph &lt;Example7&gt;&quot;);

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