I have been googling this problem forever now but have not found a solution, hopefully someone here can help (or tell me that it can't be done).
I have a JavaEE6 app that needs to connect to one or more databases which it does not know about at compile/deploy time.
A connection pool has been defined for each database in the application server the JavaEE6 app is deployed on (Glassfish 3.0.1) and each connection pool has a JNDI name like jdbc/db1, jdbc/db2 and so on.
Normally one would just create a simple persistence.xml file with persistence unit definitions for the databases and be done with it, but that won't work for this scenario because the JavaEE6 app gets set up at different clients that have different databases.
On the client side, I have a Adobe Flex application which has a client/database specific UI for querying these databases and this app needs to be able to send a query to the JavaEE6 app asking it to run a certain query against a certain database.
There is no ORM involved, I'm just using JPA native queries, and as I said, datasources for any databases are available in the app server via JNDI. The only thing I need is to be able to add persistence units dynamically because I don't want to have to create and package a different persistence.xml file for each client.
Does anyone have a solution to this problem or can this simply not be done with JavaEE/JPA ?