LoadFramesOntologyFromDB

From Protege Wiki
Revision as of 16:42, February 22, 2008 by JenniferVendetti (talk | contribs) (migrating this page from old cim3 wiki)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How do I load a Protege-Frames ontology from a Protege Database using the API?

Method 1

The simplest way to load a Protege-Frames ontology from a database is to programatically load the project file (.pprj), which already contains all of the necessary database connection information:

Project prj = Project.loadProjectFromFile("/tmp/newspaper.pprj",errors);
KnowledgeBase kb = prj.getKnowledgeBase();
...


Method 2

The second method should be used if there is no project file (.pprj) associated with the Protege-Frames database ontology:

DatabaseKnowledgeBaseFactory factory = new DatabaseKnowledgeBaseFactory();
Collection errors = new ArrayList();

Project project = Project.createNewProject(factory, errors);
//replace the arguments with your own specific values
DatabaseKnowledgeBaseFactory.setSources(project.getSources(), "com.mysql.jdbc.Driver", "jdbc:mysql://localhost/protege", "table", "user", "password");

project.createDomainKnowledgeBase(factory, errors, true);

//the following lines are optional. Use them only if you want to save the project
project.setProjectURI(new URI("file:/tmp/newspaper_saved.pprj"));
project.save(errors);
...