Hi,
I think that this might be a bug in 0.9.6 that has since been
resolved, although I'm not 100% sure. Note that 0.9.6 is pretty old at
this point.
Also, you shouldn't need to specify the properties both in the
persistence.xml and when you obtain the EMF -- just one spot is good
enough.
Are you registering your DataSource implementation in JNDI? Another
possible approach is to just specify the full classname of your
DataSource implementation, and OpenJPA will instantiate it. For
details about this, see:
http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_dbsetup_thirdparty
Can you send the full stack trace also?
-Patrick
On 7/13/07, Janap <[EMAIL PROTECTED]> wrote:
Hello,
I want to know if it is possible to create an instance of EntityManager
using the connection properties(i.e not only Username and Pwd but also
ConnectionURL and jdbc driver).
In other words, I want to use EntityManager for each user session and close
it when the user logs out. I know this is out of place but I dont want to
implement any sort of pooling.
The ideal architecture would be to create an instance of
EntityManagerFactory(when Tomcat starts) in application scope. Further I
want to use this factory to create an EntityManager when a user logs in.
Any ideas if it is possible or not?
I implemented a simple DataSource interface which returns a
java.sql.Connection object.
In my persistence.xml this code works :
<property name="openjpa.ConnectionDriverName" value="util.myDataSource"/>
<property name="openjpa.ConnectionFactoryProperties"
value="PrettyPrint=true,PrettyPrintLineLength=80"/ >
<property name="openjpa.Log" value="DefaultLevel=TRACE,Tool=TRACE"/>
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("JPATest");
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Now I want to port the code into my classes :
EntityManagerFactory emf = Persistence.createEntityManagerFactory(null);
Map myProperties = new HashMap();
myProperties.put("openjpa.ConnectionDriverName","util.myDataSource");
myProperties.put("openjpa.ConnectionFactoryProperties","PrettyPrint=true,
PrettyPrintLineLength=80");
EntityManager em = emf.createEntityManager(myProperties);
em.getTransaction().begin();
But it throws the following excpetion :
Exception in thread "main" <4|true|0.9.6-incubating>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in the ConnectionDriverName
property.
thx,
Jan
--
View this message in context:
http://www.nabble.com/Configure-EntityManager-with-dynamic-connection-tf4074808.html#a11580724
Sent from the OpenJPA Users mailing list archive at Nabble.com.
--
Patrick Linskey
202 669 5907