senthilkumar ap wrote:
you meant "its own datasourse".. so i cant configure each application with its own "database"?
Typically in a JavaEE environment, database access is done through datasources. However if you have some custom way of accessing a database, you can continue doing that. It's finally upto the application on how it connects to the right database (the connection url).
and could you suggest some documents or examples to how to configure?
Actually my application is Struts with Ejb integrated, i configure the database for the first application in postgres-ds.xml file.. so if want to run one more application configured with separate database or datasource then what should i do?
So you're accessing the database through a datasource, as described in the postgres-ds.xml file. If you look in that file, it will have an entry which specifies the JNDI Name for the datasource (note that the name of the file itself doesn't matter - it is the JNDI name inside the file that is used).
If you want another datasource that operates on a different database, just create another datasource file with a different JNDI name.
Then, in each application, just reference the correct datasource (by its JNDI name).
Note that multiple applications can certainly use the same datasource if you want them to. You don't have to have a different datasource for each application. However, if each application really uses a different database, then you will need to have separate datasource files.
Joined: Dec 01, 2008
Thanks your reply, i understood what you are coming to say.. so i can create another one file which may have the name like postgres1-ds.xml and i can specify the different JNDI name there.. am i right?
Mark E Hansen
Joined: Apr 01, 2009
senthilkumar ap wrote:Thanks your reply, i understood what you are coming to say.. so i can create another one file which may have the name like postgres1-ds.xml and i can specify the different JNDI name there.. am i right?
That's right. You can create as many as you like.
Also, if you have two applications which need to access the same database, they can share a datasource if you like - or use separate datasources if you need that for some reason.
Joined: Dec 01, 2008
Could you tell how the JBOSS will pick up postgres-ds.xml's if i have more than one? will it read every postgres-ds compulsorily ?
You can have multiple *-ds.xml files (hence the use of the term "*-ds.xml" to describe them). You can name them anything you like (for example, one-ds.xml, two-ds.xm, etcl) but a typically recommended pattern is to include the database type, and at times the database name or datasource name, in the file name (example: postgresql-accounting-ds.xml). Note that this naming convention is preferred over numbering the files; in other words I recommend against using postgreslq1-ds.xml, postgresql2-ds.xml, etc. Not that it would not work, but by using a more descriptive name you can tell them apart more easily.
The application server will open and deploy every *-ds.xml file in the deploy directory.