Jena is a semantic web framework implemented in Java. It allows you to store/query/inference RDF/RDSF/OWL triples. In Jena a set of triples (in RDF) are called Model or stored within Model object. By default Jena creates in-memory models, but this is not suitable if you have pretty large set of triples to process. Here comes SDB to rescue you. It’s a component of Jena that allows you to store these models in relational databases like MySQL, MSSQL, PostgreSQL, Oracle, etc; This post describes my experience while setting up SDB on Ubuntu.
- Download SDB. Extract it into some folder.
- SDB works with SUN Java only. Ubuntu has GNU Java installed by default. You need to install SUN Java and set it as default.
[Note: you know why this point is important? I wasted 1 hr when I did same setup second time. Later I realized I was using GNU libgcj (gij/gcj). For god’s sake, someone please kill gcj…
- Create a database for SDB in MySQL. I did using phpMyAdmin. Let’s call this database SDB2.
- Prepare a store description file. It serves as config for SDB and contains information like where to connect. You will find one such example file in the SDB directory. Here is an example for the description file I have used:
@prefix sdb: <http://jena.hpl.hp.com/2007/sdb#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix ja: <http://jena.hpl.hp.com/2005/11/Assembler#> .
# MySQL - InnoDB
<#store> rdf:type sdb:Store ;
sdb:layout "layout2" ;
sdb:connection <#conn> ;
sdb:engine "InnoDB" ; # MySQL specific
<#conn> rdf:type sdb:SDBConnection ;
sdb:sdbType "MySQL" ; # Needed for JDBC URL
sdb:sdbHost "localhost" ; # or the IP address of the database server
sdb:sdbName "SDB2" ; # MySQL database name
sdb:driver "com.mysql.jdbc.Driver" ;
- Set environment variables:
SDB installation directory –
Path to MySQL JDBC commector jar which contains
- Required tables must be created in database before we can use it. Run following to initialize
SDB2database. This creates 4 tables inside
bin/sdbconfig --sdb=sdb.ttl --create
If this fails, somthing went wrong with settings. Check them again.
- Next you can run test suit to ensure everything is working fine.
bin/sdbtest --sdb=sdb.ttl testing/manifest-sdb.ttl
In my case one testcase failed stating –
Failure: Unicode-5(com.hp.hpl.jena.sdb.test.junit.QueryTestSDB): Results sets not the same
I decided to write this as the SDB wiki does now contains clear steps to follow. Hope your semantic (web) application ROCKS !
- Setting Default JVM on Ubuntu
- Google अनुवाद