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:sdbUser "username";
sdb:sdbPassword "password";
sdb:driver "com.mysql.jdbc.Driver" ;
.
- Set environment variables:
SDB installation directory –
export SDBROOT="/home/ankit/tmp/SDB"Path to MySQL JDBC commector jar which contains
com.mysql.jdbc.Driverclass.
export SDB_JDBC="/home/ankit/tmp/SDB/mysql-connector-java-5.1.7-bin.jar" - Required tables must be created in database before we can use it. Run following to initialize
SDB2database. This creates 4 tables insideSDB2.
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.ttlIn 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 !
- ankit
One Comment
hi,
i am also facing the same problem. getting the same message u got. will that be a problem in connecting SDB and mysql? pls reply..
Post a Comment