db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Vogel <timo...@vogelware.com>
Subject RE: Shutdown Derby database using JPA not DriverManager
Date Mon, 02 Jan 2017 14:33:47 GMT
Christian,
  Good to hear from you again.  Hope all is well! 

  The "OSGI application" is an Eclipse RCP client, not a server side implementation.  I'm
using RESOUCE_LOCAL as recommended with an SE application.  Derby is used in embedded mode
within the same JVM as the client.

  I am hoping there is either an undocumented capability within Derby or a way to get the
DriverManager class from JPA provider (EclipseLink).  Failing those options, I will have to
stop / restart the client multiple times.

Tim  

-----Original Message-----
From: Christian Schneider [mailto:cschneider111@gmail.com] On Behalf Of Christian Schneider
Sent: Monday, January 2, 2017 07:32
To: Derby Discussion <derby-user@db.apache.org>
Subject: Re: Shutdown Derby database using JPA not DriverManager

You should avoid using Persistence.createEntityManagerFactory. It does not work well in OSGi.
Instead use Aries JPA or Aries transaction control.
Both can provide you with a fully configured EntityManagerFactory and EntityManager that copes
well with the dynamics of OSGi.

Christian

On 02.01.2017 12:52, Timothy Vogel wrote:
> 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);
>
> Persistence.xml
>      <properties>
> 		<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" />
> 	</properties>
>
>
> At one point in the application, I need to stop the underlying Derby database. All of
the examples show calling:
>      Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>      DriverManager.getConnection("jdbc:derby:pathToDb;shutdown=true");
>
> This is problematic, especially in an OSGI application with multiple class loaders. I
have tried using
>      if (factory.isOpen())
> 			factory.close();
> 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?
>


--
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Mime
View raw message