Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Database to RDF mapping engine and SPARQL server
Failed to load latest commit information.
.settings Merge branch 'master' of
doc Workaround for broken namespace
etc cleaner logging for Turtle parse errors
lib Update PostgreSQL driver to version 9.2-1003
src Bugfix: Make d2rq:lang usable with d2rq:sqlExpression
test/de/fuberlin/wiwiss/d2rq enhanced vendor specific db behaviour
webapp Update web.xml
.classpath Update .classpath
.gitattributes try fixing newline issue in shell scripts on cygwin
.gitignore fix several war build issues with recent Tomcat versions
.project re-rename Give more detailed build instructions, incl. prerequisites prepare v0.8.2-dev
build.xml addded before/after db cleanup methods to allow for vendor specific b…
d2r-query make shell scripts more portable (cygwin/mingw32)
d2r-query.bat git thinks these files are modified?
d2r-server make shell scripts more portable (cygwin/mingw32)
d2r-server.bat git thinks these files are modified?
dump-rdf make shell scripts more portable (cygwin/mingw32)
dump-rdf.bat git thinks these files are modified?
generate-mapping make shell scripts more portable (cygwin/mingw32)
generate-mapping.bat git thinks these files are modified?

D2RQ – A Database to RDF Mapper

D2RQ exposes the contents of relational databases as RDF. It consists of:

  • The D2RQ Mapping Language. Use it to write mappings between database tables and RDF vocabularies or OWL ontologies.
  • The D2RQ Engine, a SPARQL-to-SQL rewriter that can evaluate SPARQL queries over your mapped database. It extends ARQ, the query engine that is part of Apache Jena.
  • D2R Server, a web application that provides access to the database via the SPARQL Protocol, as Linked Data, and via a simple HTML interface.

Homepage and Documentation

Learn more about D2RQ at its homepage:


Apache License, Version 2.0

Contact, feedback, discussion

The project's mailing list is here:

Also check the open issues here on GitHub for feature/bug discussion.

Building from source


You need some tools in order to be able to build D2RQ. Depending on your operating system, they may or may not be already installed.

  • git, for forking the source code repository from GitHub. Run git on the command line to see if it's there.
  • Java JDK v5 or later, for compiling Java sources. Run java -version and javac on the command line to see if it's there.
  • Apache Ant, for building D2RQ. Run ant on the command line to see if it's there.

Getting the source

Get the code by forking the GitHub repository and cloning your fork, or directly clone the main repository:

git clone

Doing Ant builds

D2RQ uses Apache Ant as its build system. You can run ant -p from the project's main directory to get an overview of available targets:

To run the D2RQ tools, you need to do at least ant jar.

ant all Generate distribution files in zip and tar.gz formats
ant clean Deletes all generated artefacts
ant compile Compile project classes
ant compile.tests Compile test classes
ant jar Generate project jar file
ant javadoc Generate Javadoc API documentation
ant tar Generate distribution file in tar.gz format
ant test Run tests
ant vocab.config Regenerate Config vocabulary files from Turtle source
ant vocab.d2rq Regenerate D2RQ vocabulary files from Turtle source
ant war Generate war archive for deployment in servlet container
ant zip Generate distribution file in zip format

Running D2RQ

After building with ant jar, you can test-run the various components. Let's assume you have a MySQL database called mydb on your machine.

Generating a default mapping file

./generate-mapping -u root -o mydb.ttl jdbc:mysql:///mydb

This generates a mapping file mydb.ttl for your database.

Dumping the database

./dump-rdf -m mydb.ttl -o dump.nt

This creates dump.nt, a dump containing the mapped RDF in N-Triples format.

Running D2R Server

./d2r-server mydb.ttl

This starts up a server at http://localhost:2020/

Deploying D2R Server into a servlet container

Edit /webapp/WEB-INF/web.xml to point the configFile parameter to the location of your mapping file.

Build a war file with ant war.

Deploy the war file, e.g., by copying it into the servlet container's webapps directory.

Running the unit tests

The unit tests can be executed with ant test.

Some unit tests rely on MySQL being present, and require that two databases are created:

  1. A database called iswc that contains the data from /doc/example/iswc-mysql.sql:

    echo "CREATE DATABASE iswc" | mysql -u root mysql -u root iswc < doc/example/iswc-mysql.sql

  2. An empty database called D2RQ_TEST.

Something went wrong with that request. Please try again.