| [news.eclipse.rt.eclipselink] Re: use one connectio nper user - no connection pool |
That most definitely works, because that is the way I do it. Has been running in production for a year now:
static public EntityManagerFactory createEntityManagerFactory(Class jdbcDriver, String jdbcUrl, String jdbcUsr, String jdbcPwd)
{
Map<String, Object> lOptions = new HashMap<String, Object>();
lOptions.put(PersistenceUnitProperties.JDBC_DRIVER, jdbcDriver);
lOptions.put(PersistenceUnitProperties.JDBC_URL, jdbcUrl);
lOptions.put(PersistenceUnitProperties.JDBC_USER, jdbcUsr);
lOptions.put(PersistenceUnitProperties.JDBC_PASSWORD, jdbcPwd);
lOptions.put(PersistenceUnitProperties.TARGET_DATABASE, InformixPlatform.class.getName());
lOptions.put(PersistenceUnitProperties.TARGET_SERVER, TargetServer.None);
lOptions.put(PersistenceUnitProperties.JOIN_EXISTING_TRANSACTION, "true"); // reads and write should go through the same connection
lOptions.put(PersistenceUnitProperties.CACHE_SHARED_DEFAULT, "false"); // do not use the shared cache (otherwise refresh will not update from db)
lOptions.put(PersistenceUnitProperties.LOGGING_EXCEPTIONS, "true");
EntityManagerFactory lEntityManagerFactory = Persistence.createEntityManagerFactory("reinders", lOptions);
// done
return lEntityManagerFactory;
}Tom
Oh, I see. You mean setting the user and password properties at the EntityManager like this:
HashMap map = new HashMap(); map.put(EntityManagerProperties.JDBC_USER, "John"); map.put(EntityManagerProperties.JDBC_USER, "pass"); emf.createEntityManager(map);
If you meant that. this didn't work. Unfortunately this Results in a login using "" as username, which I consider a bug.
If did not mean that, sorry, then I couldn't follow you. Could you provide me with a little snippet then? Sorry if I'm puzzled. Please set me straight.
tbee schrieb:No. I mean "Em1" and "Em2", each having its own user set using the properties parameter in Java.
Are you configuring the users in the persistence.xml?
Tom