Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Parameterizing connection info at runtime rather then in persistence.xml

Hello,

I am building a webapp using ElcipseLink JPA and DB2.  I don't know
the host/port nor user/password at build time, so I want to know how
to parameterize this info at runtime.

I came across this Wiki posting which suggested I could do something like:

Map<String, String> properties = new HashMap<String, String>();
properties.put("javax.persistence.jdbc.url",

"jdbc:db2://localhost:50000/DEMO:retrieveMessagesFromServerOnGetMessage=true;");
properties.put("javax.persistence.jdbc.user", "demo");
properties.put("javax.persistence.jdbc.password", "demoui%$");
EntityManager em = emf.createEntityManager(properties);

However, it looks like these properties are not getting passed down
into the ElcipseLink mechanism.  Any ideas?

Thanks,

Chris Wolf


[EL Config]: connection: 2015-03-04
15:23:53.151--ServerSession(477106221)--Connection(-2088661038)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>DB2Platform
user name=> ""
datasource URL=> "null"
))
[EL Severe]: 2015-03-04
15:23:53.164--ServerSession(477106221)--Thread(Thread[main,5,main])--Local
Exception Stack:
Exception [EclipseLink-4021] (Eclipse Persistence Services -
2.5.1.v20130918-f2b9fc5):
org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver
[com.ibm.db2.jcc.DB2Driver], user [null] and URL [null].  Verify that
you have set the expected driver class and URL.  Check your login,
persistence.xml or sessions.xml resource.  The jdbc.driver property
should be set to a class that is compatible with your database
platform
at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:383)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:346)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:307)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:434)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:217)
at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:505)
at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:488)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:755)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:241)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:304)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:336)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:309)
at com.ibm.algo.cards.svcmgr.dbtest.JPAEntityTestLowLevel.test(JPAEntityTestLowLevel.java:59)


Back to the top