Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » dynamically configure javax.persistence.jdbc.url?(How to change an embedded dB on the fly)
dynamically configure javax.persistence.jdbc.url? [message #531822] Thu, 06 May 2010 09:55 Go to next message
Olu  is currently offline Olu
Messages: 29
Registered: October 2009
Junior Member
Hi,
I'm writing a desktop app in Jave SE and want to be able to enable the users to change the embedded JavadDB database they are working from on the fly.

Does any know if there is a way to pgramatically change the value of javax.persistence.jdbc.url and effectively restart the app?

I guess the longer (possibly "proper") way of doing this would be to make the modification/dB selection from a separate launcher app which makes the change to the url and restarts the main windown app.....anyone know a framework for doing this?

thanks,
Re: dynamically configure javax.persistence.jdbc.url? [message #531834 is a reply to message #531822] Thu, 06 May 2010 10:16 Go to previous messageGo to next message
Tom Eugelink is currently offline Tom Eugelink
Messages: 807
Registered: July 2009
Senior Member
On 2010-05-06 11:55, Olu wrote:
> Hi,
> I'm writing a desktop app in Jave SE and want to be able to enable the
> users to change the embedded JavadDB database they are working from on
> the fly.
>
> Does any know if there is a way to pgramatically change the value of
> javax.persistence.jdbc.url and effectively restart the app?
>
> I guess the longer (possibly "proper") way of doing this would be to
> make the modification/dB selection from a separate launcher app which
> makes the change to the url and restarts the main windown app.....anyone
> know a framework for doing this?
>
> thanks,

Like this?

Map<String, Object> lOptions = new HashMap<String, Object>();
lOptions.put(PersistenceUnitProperties.JDBC_DRIVER, lDriver);
lOptions.put(PersistenceUnitProperties.JDBC_URL, lUrl);
lOptions.put(PersistenceUnitProperties.JDBC_USER, lUsr);
lOptions.put(PersistenceUnitProperties.JDBC_PASSWORD, lPwd);
lOptions.put(PersistenceUnitProperties.TARGET_DATABASE, "Informix");
lOptions.put(PersistenceUnitProperties.TARGET_SERVER, TargetServer.None);
EntityManagerFactory lEntityManagerFactory = Persistence.createEntityManagerFactory("xxxx", lOptions);
Re: dynamically configure javax.persistence.jdbc.url? [message #532334 is a reply to message #531834] Sat, 08 May 2010 13:00 Go to previous message
Olu  is currently offline Olu
Messages: 29
Registered: October 2009
Junior Member
thanks - looks good and will try it out.
Previous Topic:[Unidirectional OneToOne Relationships] eclipselink doesn't understand MapsId=" "
Next Topic:CreateNativeQuery ResultSet mapping
Goto Forum:
  


Current Time: Wed Oct 22 00:07:35 GMT 2014

Powered by FUDForum. Page generated in 0.02365 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software