DB2 Version 10.1 for Linux, UNIX, and Windows

Setting up SPARQL Version 1.1 Graph Store Protocol and SPARQL over HTTP

In DB2® Version 10.1 Fix Pack 2 and later fix packs, DB2 RDF supports the SPARQL Version 1.1 graph store HTTP protocol. This protocol requires Apache JENA Fuseki Version 0.2.4. You need to set up the Fuseki environment to use the SPARQL REST API.

Before you begin

To set up the Fuseki environment:
  1. Download the jena-fuseki-0.2.4-distribution.zip file from http://archive.apache.org/dist/jena/binaries/.
  2. Extract the file on your local system.

Procedure

  1. Open a command prompt window and go to the <Fuseki install dir>/jena-fuseki-0.2.4 directory.
  2. Open the config.ttl file and add db2rdf as a prefix
    @prefix :        <#> .
    @prefix fuseki:  <http://jena.apache.org/fuseki#> .
    @prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
    @prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
    
    @prefix db2rdf:  <http://rdfstore.ibm.com/IM/fuseki/configuration#> 
  3. Add the DB2 RDF service to the config.ttl file. Add this service to the section of the file where all the other services are registered.
    fuseki:services (
         <#service1>
         <#service2>
          <#serviceDB2RDF_staffing>
       ) .

    You can register multiple services. Each service queries different DB2 RDF data sets.

  4. Add the following configuration to the config.ttl file to initialize the RDF namespace. This configuration registers the assembler that creates the DB2Dataset. The configuration also registers the DB2QueryEngine and DB2UpdateEngine engines.
    # DB2 
    [] ja:loadClass "com.ibm.rdf.store.jena.DB2" .
    db2rdf:DB2Dataset  rdfs:subClassOf  ja:RDFDataset .
  5. Add details about the DB2 RDF service to the end of config.ttl file.
    # Service DB2 Staffing store
    <#serviceDB2RDF_staffing>
    rdf:type fuseki:Service ;
    rdfs:label "SPARQL against DB2 RDF store" ;
    fuseki:name "staffing" ; 
    fuseki:serviceQuery "sparql" ;
    fuseki:serviceQuery "query" ;
    fuseki:serviceUpdate "update" ;
    fuseki:serviceUpload "upload" ;
    fuseki:serviceReadWriteGraphStore "data" ; 
    fuseki:serviceReadGraphStore "get" ;
    fuseki:serviceReadGraphStore "" ; 
    fuseki:dataset <#db2_dataset_read> ;
    .
    
    <#db2_dataset_read> rdf:type db2rdf:DB2Dataset ;
    
    # specify the RDF store/dataset and schema
    db2rdf:store "staffing" ;
    db2rdf:schema "db2admin" ;
    
    # Database details. Specify either a jdbcConnectString
    # with username and password or specify a jndiDataSource
    db2rdf:jdbcConnectString "jdbc:db2://localhost:50000/RDFSAMPL" ;
    db2rdf:user "db2admin" ;
    db2rdf:password "db2admin" .
    
    #db2rdf:jndiDataSource "jdbc/DB2RDFDS" .
  6. Issue the following commands from the command line:
    SET CLASSPATH=./fuseki-server.jar;<DB2_FOLDER>/rdf/lib/rdfstore.jar;
    <DB2_FOLDER>/rdf/lib/wala.jar;<DB2_FOLDER>/rdf/lib/antlr-3.3-java.jar;
    <DB2_FOLDER>/rdf/lib/commons-logging-1-0-3.jar;<DB2_FOLDER>/java/db2jcc4.jar;
    %CLASSPATH%;
    
    java org.apache.jena.fuseki.FusekiCmd --config config.ttl

Results

  1. Start your browser and load the localhost:3030 URL. The Fuseki page loads in the browser window.
  2. Click the Control Panel hyperlink in the browser window and select Dataset from the drop-down list. The drop-down list contains all the data sets that are listed in the config.ttl file. Select the data set that you configured.
  3. Issue a SPARQL query by using the options from the GUI. The first section is for querying the data set with the SPARQL query language. The second section is for modifying the data set with SPARQL updates. The third section is for loading data into the graphs in the data set.