persistence@glassfish.java.net

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

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Fri, 23 Nov 2007 15:59:30 +0000

Hello Nicolas,

Are you using Sun application server 9 or Glassfish server? as application server?
If so, then you can set up the connection pool in your admin console.
Set up the JNDI - jdbc reference name in the admin console. You will
then use this to set up your persistence unity and then provide the persistence
unit name to the
@PersistenceContext("persisunitname")
EntityManager em;

You can then set data and retrieve data from the DB.

>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....)>

What do you mean by the above?

Where would you be calling/stating the @PersistenceContext?

In an implementation class or an application client or a web (serlvet)?

it should work provided you import the appropriate java packages:

import javax.ejb.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

I hope that helps? If you require more information about setting the connection pool, then let us know.

eve








Date: Thu, 22 Nov 2007 13:24:33 +0100
From: nicolas.gaudin_at_mfpsoft.com
To: persistence_at_glassfish.dev.java.net
Subject: Programmatically define persistence properties (url, usr, pwd, driver,...)








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  
    
    
        Responsable
Technique Solutions Web  
    
    
        Tel
:
Mobile :  
        05
62 57 14 29 
06 69 58 86 05  
    
    
    
    
       
        
       
       
        Immeuble
Stratège – Bâtiment 1
Rue Ampère – BP 57213
LABEGE CEDEX  
    
  
_________________________________________________________________
Celeb spotting – Play CelebMashup and win cool prizes
https://www.celebmashup.com





logo_web.gif
(image/gif attachment: logo_web.gif)

logo.gif
(image/gif attachment: logo.gif)