Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-discussion] (Protege Server 3.4.3 database-backend) connections to db are not released

Timothy Redmond tredmond at stanford.edu
Tue Feb 23 05:54:00 PST 2010


sonre wrote:
> Dear Timothy Redmond, after some examination, we observed that the large
> number connections come from the imported ontologies. Although the same
> ontologies are imported by different projects, a new connection is open for
> each import again and again. Here are the details:
>   
This makes sense because it is a case that has not been tested here.  
Without looking again at the code, my reaction is that this should 
work.  It could be a bug.  The connection pool should see that the 
connection parameters are the same for the imports and use a common 
connection.  My recollection was that I used a static mapping to track 
the mapping of the connection urls to the pools.  I will have to take a 
look.

At a first glance your code looks good and looks like it should work 
perfectly.

-Timothy


> 1- We have 33 projects all of which imports the same 5 ontologies.
> 2- When we start the Protege server, we observe (with mysql administrator)
> that 166 new connections are opened. We guess that 33*5 = 165 connections
> are open for the imports and 1 connection is shared by all 33 projects (main
> owl files). 
> 3- When we create a new project with no imports, 1 new connection is opened.
> When we restart the server this connection is not opened again. So, the
> total # of connections are not changed.
> 4- When we create a new project with 5 imports, 6 new connections are
> opened. When we restart the server, we observe the total # of connections
> are increased by 5.
>
> Therefore, we think that there is a problem with our import mechanism or
> it's a bug.
>
> Here is the code for creating a db project on server. This function is
> called for creating a new project with the name "newProjectName":
>
> public Project createDBProject(String newProjectName) {
>
> String db_url = "jdbc:mysql://localhost:3306/protege";
> String db_driver = "com.mysql.jdbc.Driver";
> String db_user = "root";
> String db_pass = "pass";
>
> Collection errors = new ArrayList();
> OwlDatabaseCreator creator = new OwlDatabaseCreator(true);
> creator.setDriver(db_driver);
> creator.setURL(db_url);
> creator.setTable(newProjectName);
> creator.setUsername(db_user);
> creator.setPassword(db_pass);
>
> DatabaseRepository repository = new DatabaseRepository(db_driver, db_url,
> db_user, db_pass, "import1");
> repository.addTable("import1");
> repository.addTable("import2");
> repository.addTable("import3");
> repository.addTable("import4");
> repository.addTable("import5");
> creator.addRepository(repository);
> creator.create(errors);
>
> Project p = creator.getProject();
> p.setProjectURI(URIUtilities.createURI("ontology" + File.separator +
> newProjectName + ".pprj"));
> KnowledgeBase kb = p.getKnowledgeBase();
> OWLModel owlModel = (OWLModel)kb;
> 	
> owlModel.getTripleStoreModel().getTopTripleStore().setOriginalXMLBase("http://www.mac_instances.com/"
> + newProjectName + ".owl#");
> String defaultNameSpace = "http://www.mac_instances.com/" + newProjectName +
> ".owl#";
> owlModel.getNamespaceManager().setDefaultNamespace(defaultNameSpace);
>
> ImportHelper importHelper = new ImportHelper(owlModel);
> Collection prefixes = new
> ArrayList(owlModel.getNamespaceManager().getPrefixes());
> Collection<URI> uris = repository.getOntologies();
> for(URI uri:uris) {
> 	importHelper.addImport(uri);
> }
>
> importHelper.addImport(repository.getTableToOntologyMap().get("scm")); //
> for some reason import5 is not added by the loop above, so we add it again
> manually. Note: import5 is the main schema.
> importHelper.importOntologies();
> owlModel.getNamespaceManager().setPrefix("http://isl.ceng.metu.edu.tr/futbol_yeni3.owl#","p1");
>
> p.save(errors);
> return p;
> }
>
> Note: These 5 imports are also db projects, created with the same
> db_url,driver,user and pass. Only difference is that they are created with
> Protege User Interface with the command "Convert Project To Format -->
> OWL/RDF Database"
>
> Best Regards,
> soner
>
>   




More information about the protege-discussion mailing list