db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Vogel <timo...@vogelware.com>
Subject Shutdown Derby database using JPA not DriverManager
Date Mon, 02 Jan 2017 11:52:04 GMT
I have an OSGI application that uses Derby for persistence and Eclipse Link as a JPA provider.
 I leave starting the Derby instance to JPA and persistence.xml.  

    factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, props);

		<property name="eclipse.weaving" value="false" />
		<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"
		<property name="javax.persistence.jdbc.url" value="jdbc:derby:pathToDb" />
		<property name="eclipselink.logging.level.sql" value="FINEST" />
		<property name="eclipselink.logging.parameters" value="true" />

At one point in the application, I need to stop the underlying Derby database. All of the
examples show calling:

This is problematic, especially in an OSGI application with multiple class loaders. I have
tried using 
    if (factory.isOpen())
but this does not shutdown the Derby instance, only the JPA connection to it.

I tried using the OSGI console to stop the persistence related bundles including javax.persistence,
JPA and Derby.  Stopping these did not release the file locks that Derby put on log files.

Is there a way, using JPA, to shutdown the underlying Derby instance?

View raw message