Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] connecting with different usernames in the same process

In my application I need to make connections to 2 separate database usernames. I get the main entitymanager1,then create a second entitymanager1 with a different username. I need to get a Connection from the second entitymanager. I am using code like this:

   private Accessor getAccessor() {
        EntityManagerImpl em = (EntityManagerImpl) entityManager2;
        session = em.getServerSession();
Accessor accessor = session.getDefaultConnectionPool().acquireConnection();
        accessor.incrementCallCount(session);
        return accessor;
    }

The Connection I'm ending up with is for the username from entitymanager1, where I need a Connection from entitymanager2.

Is this because I am using getDefaultConnectionPool? How should I handle different database connections in this case?

Thanks.
=============================================
David Parker
dap@xxxxxxxxxxxxxxxxxxxx






Back to the top