Difference between revisions of "Working with the Database Backend in OWL"

From Protege Wiki
Jump to: navigation, search
(Converting a Project to a Database Project)
(Converting a Project to a Database Project)
Line 40: Line 40:
 
[[Image:OwlDatabaseBackendSelectDbSettings.png]]
 
[[Image:OwlDatabaseBackendSelectDbSettings.png]]
  
Click finish and the database project will be createdUse whatever tool is available and you will find that a table has been added to the mysql database.  In addition, it  is not difficult to show that this project is an example of a database project importing two owl projects that are loaded from the web.  To see this, close protege and save the project, turn off your internet connection and try to reload the database ontology. If you can do this
+
The jdbc:mysql://localhost/protege is parsed as follows. The jdbc:mysql: prefix says that this url is a mysql jdbc url and that the database can be loaded using jdbc with the mysql driversThe localhost says that the database is running on the local machine and the protege says to use the mysql protege database (which I confgured using mysql tools before I started.)
  
 +
Click finish and the database project will be created.  Use whatever tool is available and you will find that a table has been added to the mysql database.  In addition, it  is not difficult to show that this project is an example of a database project importing two owl projects that are loaded from the web.  To see this, close protege and save the project, turn off your internet connection and try to reload the database ontology.  If you can do this then you will see the following popup dialog
 +
 +
[[Image:OwlDatabaseBackendUnresolvedImport.png]]
 +
 +
and you will see the following exception (this is just a small bit of the full exception) on the console.
  
 
  SEVERE: Exception caught -- java.net.UnknownHostException: proton.semanticweb.org
 
  SEVERE: Exception caught -- java.net.UnknownHostException: proton.semanticweb.org
Line 51: Line 56:
 
     at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
 
     at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
 
     at sun.net.www.http.HttpClient.New(HttpClient.java:304)
 
     at sun.net.www.http.HttpClient.New(HttpClient.java:304)
 +
 +
What these messages mean is that Protege needed to get the imported ontologies from the internet but was  unable to find them.  The next step is to show how to put all the data on the local machine so that

Revision as of 14:36, April 21, 2008

Working with the Database Backend in OWL

Before you start

This example requires that the mysql jdbc drivers are available to Protege. To make the drivers available, download the drivers from here, copy the jar file into the Protege installation directory and call it driver.jar. In theory, any jdbc database should work but we have only done testing for mysql, postgres, oracle 9g and the microsoft sql server. The drivers for all of these options can be found here.

Opening an ontology using a web uri

This note will show by example how to convert an owl project and its imports to a database backend project. We will use the proton ontology as an example because it has a few non-trivial imports. The first step is to open it from the web. We start protege and in the welcome screen we select "New Project".

OwlDatabaseBackendProtegeWelcome.png

Note that if Protege is already open and you don't see the welcome screen then you can access the screen below by clicking on the File menu and selecting "New Project".

Now since we want to create a Protege OWL project using a url from the internet, we

  • select Use existing sources,
  • select OWL/RDF Files and
  • click next.

OwlDatabaseBackendCreateNewProject.png

Finally we enter the url (http://proton.semanticweb.org/2005/04/protonu) for the upper Proton ontology and click finish.

OwlDatabaseBackendChooseURLAndFinish.png

Wait a bit and the ontology will come up. When it does, you will see the reason that this ontology was chosen for this demonstration when you unravel the imports in the imports tab. There are two imports (protont and protons) which occur in two different places.

OwlDatabaseBackendProtonUImports.png

Converting a Project to a Database Project

Now we will convert the upper Proton ontology to a database project. To do this click on the Protege File menu and select "Convert Project to Format". In this window select the "OWL / RDF Database" format and click ok.

OwlDatabaseBackendSelectProjectFormat.png

Once you click ok, you will see a dialog with several database settings. You can fill them as shown below. If you don't want to type out the entire path of where to save the project then press the box with a superscript + sign in the upper right hand side of the dialog and Protege will let you browse to where the project file should be saved.

OwlDatabaseBackendSelectDbSettings.png

The jdbc:mysql://localhost/protege is parsed as follows. The jdbc:mysql: prefix says that this url is a mysql jdbc url and that the database can be loaded using jdbc with the mysql drivers. The localhost says that the database is running on the local machine and the protege says to use the mysql protege database (which I confgured using mysql tools before I started.)

Click finish and the database project will be created. Use whatever tool is available and you will find that a table has been added to the mysql database. In addition, it is not difficult to show that this project is an example of a database project importing two owl projects that are loaded from the web. To see this, close protege and save the project, turn off your internet connection and try to reload the database ontology. If you can do this then you will see the following popup dialog

OwlDatabaseBackendUnresolvedImport.png

and you will see the following exception (this is just a small bit of the full exception) on the console.

SEVERE: Exception caught -- java.net.UnknownHostException: proton.semanticweb.org
   at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
   at java.net.Socket.connect(Socket.java:520)
   at sun.net.NetworkClient.doConnect(NetworkClient.java:152)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:387)
   at sun.net.www.http.HttpClient.openServer(HttpClient.java:522)
   at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
   at sun.net.www.http.HttpClient.New(HttpClient.java:304)

What these messages mean is that Protege needed to get the imported ontologies from the internet but was unable to find them. The next step is to show how to put all the data on the local machine so that