-
1. Re: JBoss AS 7 - Datasource Management WebApp
nickarls Sep 26, 2012 1:46 AM (in response to daniel.todt)1 of 1 people found this helpfulThe 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.
-
2. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Sep 26, 2012 6:47 AM (in response to nickarls)Thanks, I'll try it.
If I still have some questions, I'll post here again.
-
3. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Sep 26, 2012 7:31 AM (in response to nickarls)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?
Thank you.
-
4. Re: JBoss AS 7 - Datasource Management WebApp
nickarls Sep 27, 2012 1:32 AM (in response to daniel.todt)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?)
-
5. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Sep 27, 2012 9:25 AM (in response to nickarls)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.
Thank you.
<< EDIT: >>
I may have found a possible solution, this:
http://stackoverflow.com/questions/9704715/how-to-list-jboss-as-7-datasource-properties-in-java-code
I'll do some tests, but I think this is what I'm looking for.
Message was edited by: Daniel Otavio Todt
-
6. Re: JBoss AS 7 - Datasource Management WebApp
nickarls Sep 28, 2012 1:53 AM (in response to daniel.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.
-
7. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Oct 3, 2012 10:03 AM (in response to nickarls)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.
Thank you.
-
8. Re: JBoss AS 7 - Datasource Management WebApp
nickarls Oct 3, 2012 2:28 PM (in response to daniel.todt)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?
-
9. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Oct 3, 2012 3:29 PM (in response to nickarls)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.
-
10. Re: JBoss AS 7 - Datasource Management WebApp
nickarls Oct 4, 2012 2:02 AM (in response to daniel.todt)And it has to be JPA type "sql commands" so a normal jdbc connection won't do?
-
11. Re: JBoss AS 7 - Datasource Management WebApp
daniel.todt Oct 4, 2012 7:31 AM (in response to nickarls)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.
Thank you.