Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Toplink essentials: Create EntityManagers with different username/password

alexs12345678Nov 14 2006 — edited Nov 20 2006
Hi everybody!

I would like to use the TopLink JPA implementation for my Servlet Web Applikation running on TomCat, but I have a few open Questions.

As far as I know a EntityManagerFactory should be created once for a application. But I cant use the same user/password for each user, I need a named user. I have found out that I can make a property map with username and password and create a EntityManagerFactory like this:

Map<String, String> connectProps = new HashMap<String, String>();
connectProps.put(TopLinkProperties.JDBC_USER, "myusername");
connectProps.put(TopLinkProperties.JDBC_PASSWORD,"myuserpassword");
EntityManager emf = Persistence.createEntityManagerFactory("default", connectProps);

But this property map does not work with the method createEntityManager(properties) from the EntityManagerFactory, (emf.createEntityManager(connectproperties) I always get a illegal argument exception.

I found in the Open JPA documentation that it should be possible there to create EntityManagers with the .createEntityManager(Map properties) and define username / password in the property map.

Is it a limitation of the Oracle Toplink JPA implementation that only a EntityManagerFactory accepts username/password for creation?

Many thanks for your help,
Best regards,
Alex Schaefer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 18 2006
Added on Nov 14 2006
5 comments
579 views