Posts tagged ‘SDB’
JOSEKI with SDB and MySQL
2. Install SDB from http://sourceforge.net/projects/jena/files/SDB/
Download the zip file, in my case, I stored the zip file sdb-1.3.1.zip in \usr\local\SDB_svn
3. unzip SDB-1.3.1.zip
This will create a directory SDB-1.3.1 under \usr\local\SDB_svn
All the SDB arsenal is located inside SDB-1.3.1
4. Install MySql
4.1 sudo apt-get install mysql-server
4.2 sudo apt-get install mysql-query-browser
4.3 mysql -u root -p
you will be prompted to enter password.
4.5 create database rdf2wav CHARACTER SET UTF8
5. Create a file sdb.ttl under \usr\local\SDB_svn\SDB-1.3.1
Write the following in sdb.ttl (dont include ##############)
#######################################
# See Store/ for example sdb files.
@prefix sdb: .
@prefix rdfs: .
@prefix rdf: .
@prefix ja: .
# MySQL – InnoDB
rdf:type sdb:Store ;
sdb:layout “layout2″ ;
sdb:connection ;
sdb:engine “InnoDB” ; # MySQL specific
.
rdf:type sdb:SDBConnection ;
sdb:sdbType “MySQL” ; # Needed for JDBC URL
sdb:sdbHost “localhost” ; # or the IP address of the database server
sdb:sdbName “rdf2wav” ; # MySQL database name
sdb:sdbUser “root”; #mysql user name
sdb:sdbPassword “bike”; #mysql password
sdb:driver “com.mysql.jdbc.Driver” ;
.
########################################
6. Write the following in .bashrc of your home directory
#####################################
export SDBROOT=/usr/local/SDB_svn/SDB-1.3.1
export SDB_JDBC=/usr/local/SDB_svn/SDB-1.3.1/lib/mysql-connector-java-5.1.12-bin.jar
export PATH=$PATH:$SDBROOT
export CLASSPATH=/usr/local/SDB_svn/SDB-1.3.1/lib/sdb-1.3.1.jar
#####################################
Note that, you need to download mysql-connector-java-5.1.12-bin.jar inorder to connect SDB with the SqlServer. If you dont have it, download it and store it in the lib forder of SDBROOT.
7. Restart the terminal and execute the following command, which will create 4 tables
bin/sdbconfig –sdb-sdb.ttl –create
The four tables that were created are
Nodes, Prefixes, Quads, and Triples.
8. format the tables
bin/sdbconfig –sdb=sdb.ttl –format
9. Run the test suite
bin/sdbconfig -v –time -sdb=sdb.ttl testing/manifest-sdb.ttl
if this runs fine with no error, then everything is correct until now.
10. Load the RDF data
bin/sdbload -v –time -sdb=sdb.ttl /path/to/your/rdffile
ex:
bin/sdbload -v –time -sdb=sdb.ttl /usr/local/hadoop/I0/University0_0.owl
or
bin/sdbload -v –time -sdb=sdb.ttl /usr/local/hadoop/I0/*
The last statement is useful if you have multiple RDF files.
The statement above will load the RDF data in the MySql tables.
11. Execute the query
bin/sdbquery -v –time -sdb=sdb.ttl ‘select ?x ?y ?z where {?x ?y ?z} limit 10′
If you get results, then SDB is configured with MySql to execute SPARQL queries
12. Next step is to configure JOSEKI with SDB and MySql
modify the data section of joseki-config-sdb.ttl and rename it as joseki-config.ttl
My joseki-config.ttl data section looks like this
rdf:type sdb:Store ;
rdfs:label “SDB” ;
sdb:layout “layout2″ ;
sdb:connection
[ rdf:type sdb:SDBConnection ;
sdb:sdbType "MySql" ;
sdb:sdbHost "localhost" ;
sdb:sdbName "rdf2wav" ;
sdb:sdbUser "root";
sdb:sdbPassword "bike";
]
.
13. Start rdf server
bin/rdfserver
The above statement execute from the terminal. Start the terminal, go to the JOSEKI installation folder.
14. http://localhost:2020 for testing SPARQL query