Hi!
Try this:
================ CODE EXAMPLE ================
// Generate a map containing your properties
HashMap<String, String> connnectionProperties = new HashMap<String, String>();
// Set your properties as you like:
connnectionProperties.put(PersistenceUnitProperties.JDBC_USER, "user");
connnectionProperties.put(PersistenceUnitProperties.JDBC_USER, "password");
// Pass the properties map to your EntityManager Factory
EntityManagerFactory emf = javax.persistence.Persistence.createEntityManagerFactory("GollumPU", connnectionProperties);
EntityManager em = emf.createEntityManager();
================ CODE EXAMPLE ================
Mit freundlichen Grüßen / Kind Regards
Christian Reiter
PerCom-Soft HandelsgesmbH
------->> NEU:
Direkte Erreichbarkeit über ENUM und SIP:
ENUM: +43 5242 61177 23
SIP: <sip:52426117723_at_voice.percom.at>
<<-------
--
Christian Reiter
christian@percom.at || http://www.percom.at <http://www.percom.at/>
fon: +43 5242 61177 || mob: +43 664 924 55 27 || fax: +43 5242 61177 31
________________________________
Von: zineb bentaleb [mailto:zinebbentaleb_at_menara.ma]
Gesendet: Mittwoch, 14. Januar 2009 04:12
An: persistence_at_glassfish.dev.java.net
Betreff: Fw: configure properties in persistence.xml at runtime
----- Original Message -----
From: zineb bentaleb <mailto:zinebbentaleb_at_menara.ma>
To: persistence_at_glassfish.dev.java.net
Sent: Wednesday, January 14, 2009 4:04 AM
Subject: configure properties in persistence.xml at runtime
Hello
I'm using this persistence.xml file and i want to change properties at runtime; How can I do it :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="EmployeeService" transaction-type="RESOURCE_LOCAL">
<class>com.shemsit.model.Employee</class>
<properties>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://localhost:3306/testJPA"/>
<property name="toplink.jdbc.user" value="root"/>
<property name="toplink.jdbc.password" value="root"/>
<!-- enable this property to see SQL and other logging -->
<!-- property name="toplink.logging.level" value="FINE"/ -->
<!--<property name="" value="app"/>-->
</properties>
</persistence-unit>
</persistence>
Zineb.
PerCom-Soft HandelsGesmbH
Firmenbuchnummer: FN 155246d
Firmenbuchge
richt: Landesgericht Innsbruck
Firmensitz: A-6135 Stans, Sc
hlagturn 24
Rechtsform: Gesellschaft mit beschraenkter Haftung