1 of 1 people found this helpful
The correct way would be to use the management API like https://community.jboss.org/wiki/DetypedDescriptionOfTheAS7ManagementModel etc.
Fiddle not with the standalone.xml, for it is subtle and quick to corrupt.
Thanks, I'll try it.
If I still have some questions, I'll post here again.
I thought a little complicated to understand.
This is a kind of script that my application would send to JBoss?
Can be done at runtime, ie without redeploying the application?
It's a little hard to understand because I'm beginner in this area.
I'll look for some tutorial for beginners, if you know some, could post here?
It's a complicated thing, it's supposed to be hard! ;-)
Check the link I pasted (and related links/incoming) and google around for keywords + check the forums.
Some of the operations can be made on-the-fly (adding datasources), some might require a reload (removing?)
So if I just want to get a list of pre-registered DataSources, and offer the User a selection option, it would be possible to do using that link you passed?
Thus, I would have the Connection Pools created for use within the project, I would have to use a EntityManagerFactory to manage the user's choice?
Or would a more appropriate way to do this?
Just to explain right what I'm trying to do is a test.
There will be several databases from several different providers (Oracle, MsSQL, etc.), is an indefinite number of databases.
Like a executor of database scripts. The user will be able to choose the database that want to use, and in this part on the application will connect to that database.
I'm using hibernate to manage EntityManagers, it connects to the database via JBoss JTA DataSource.
I thought one thing or another about Hibernate Multi-Tenancy, but I do not know how, nor if this would apply to my case.
I'm looking on this Hibernate Multi-Tenancy, despite not knowing exactly how it works.
<< EDIT: >>
I may have found a possible solution, this:
I'll do some tests, but I think this is what I'm looking for.
Message was edited by: Daniel Otavio Todt
Well, if you're using JPA you could bootstrap the EntityManager/EntityManagerFactory by yourself either in code or by a CDI producer method, I guess.
Hello, good morning.
So, after much work, I could list the datasources created by JBoss.
I can pick them up and list their JNDI's, but one thing I could not yet, is to convert one of these datasources in a EntityManager. When trying to convert the project generates a ClassCastException.
Obviously that is not possible to convert a datasource pool, in a EntityManager.
But how can I do it then?
Here follows my post on StackOverflow with the question I asked: http://stackoverflow.com/q/12623955/1703546.
Wonder if it would be possible to work on a higher level and start from Persistence.createEntityManagerFactory on an existing dummy PU in a persistence.xml?
Yes, if possible.
Because, as I do not know which database will be existing at the time of execution.
Can be MySQL, Oracle, MS SQL Server, etc..
I want to make that kind of user-controlled.
The user would create the datasource, using a form, and then could run sql commands through the datasource created.
And it has to be JPA type "sql commands" so a normal jdbc connection won't do?
Maybe, but I know a little of the functioning of EntityManager when I say "run sql commands", I think the "EntityManager.createNativeQuery(String)".
For there are cases where further, I want to write this command in an Entity on Database.
So I thought I'd use the EntityManager as it is "compatible" with both types of interaction with the database.