How to get DataSource or Connection from JPA2 EntityManager in Java EE 6

前端 未结 3 1375
傲寒
傲寒 2020-12-17 17:42

I have a working application where I use Java EE 6 with EclipseLink for persistence and a PostgreSQL database.

For the User-Registration I want to set the password i

3条回答
  •  清酒与你
    2020-12-17 18:13

    sometimes it just takes another run in google:

    entityManager.getTransaction().begin();
    java.sql.Connection connection = entityManager.unwrap(java.sql.Connection.class);
    ...
    entityManager.getTransaction().commit();
    

    as described in the Eclipse Link Documentation

提交回复
热议问题