Skip to Main Content

Integration

Getting a datasource from a persistence-unit

mmillmanSep 26 2008 — edited Sep 30 2008

Is there any way to get the name of the datasource (non-jta or jta) from a persistence unit via the EntityManagerFactory or EntityManager instances?

We need to do some JDBC work (for exotic data types) and are currently parsing the persistence.xml file ourselves to get the data source name (which is an awful thing to do) but would much rather be able to say

Connection conn = Utility.getConnection(EntityManger em)

or even

String datasource = Utility.getDataSource(EntityManager em)

.

Thanks, Mark

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 28 2008
Added on Sep 26 2008
6 comments
3,815 views