In a JavaEE environment, is it possible to extract the JDBC connection ( java.sql.Connection
) using JTA
?
I have a datasource in WildFly, where I inject as follows:
@PersistenceContext
private EntityManager entityManager;
Is there any way to extract the JDBC connection from this EntityManager?
I found a form (but it did not work):
Connection connection = entityManager.unwrap(java.sql.Connection.class);
The following error was thrown:
javax.persistence.PersistenceException: Hibernate can not unwrap interface java.sql.Connection