persistence@glassfish.java.net

Programmatically define persistence properties (url, usr, pwd, driver,...)

From: Nicolas Gaudin <nicolas.gaudin_at_mfpsoft.com>
Date: Thu, 22 Nov 2007 13:24:33 +0100

Hello,

I am wirintg to you after struggling on how to programmatically define
Datasource properties (driver, user, url,..) with Toplink EntityManger.

My application needs to dynamically connect to a database (MS SQL
Server..yes I know..but no choice) that is selected by the user at login
page.
Also, I want to use *EntityManger *and not datasources directly...

I am in Java EE (and not J2SE) environnement using JSF (Netbeans 6.0
VWP), EJB3, Toplink and GlassFish V2.

I would like to use CMP but I am afraid it is impossible...indeed,
according to
https://glassfish.dev.java.net/javaee5/persistence/entity-persistence-support.html
I will need to use EJB3 and persistence OUTSIDE the container => Using
@PersistenceContext annotation is not possible anymore...Is that right?
If it is the case, is that a valid solution (andin terms of perfomance....)

I found another solution as follows:
http://blogs.sun.com/JagadishPrasath/entry/creating_jdbc_connection_pool_resource#4_Creating_Connection_Pool__Resource
This seems a bit tricky to manage Galssfish resource programmatically.
Do you confirm...

*Please help me *on this as I am lost and need a solution ASAP

Many thanks in advance for your feedback
Regards,
-- 
Nicolas Gaudin <mailto:nicolas.gaudin_at_mfpsoft.com>
Responsable Technique Solutions Web
Tel :
Mobile : 	05 62 57 14 29
06 69 58 86 05
[MFP SOFT] <http://www.mfpsoft.com/>
	Immeuble Stratège -- Bâtiment 1
Rue Ampère -- BP 57213
LABEGE CEDEX