Reputation: 337
I have to deal with an API which need to be provided a DataSource as a parameter. The problem is I'm accessing it from a context that provides an EntityManager or a PersistentContext, which do not appear to expose any DataSource through its methods. How is it possible to programmatically retrieve the underlying DataSource from an EntityManager ?
Upvotes: 1
Views: 3356
Reputation: 337
Solution is injecting datasource this way :
@Resource(name = "jdbc/...")
private DataSource dataSource;
and then providing the datasource as an argument to the API.
Upvotes: 2