• Post Reply Bookmark Topic Watch Topic
  • New Topic

Datasource in web.xml  RSS feed

 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

What is the advantage of specifying datasource reference in web.xml ? Is it necessary that datasource reference should be added to web.xml?

Regards,
Ajay.
 
ak pillai
author
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can acyiure it declaratively by specifying in your web.xml something like




There's nothing stopping you from using data sources programmatically instead of declaratively. Having declarative approach is preferable because you code can concentrate more writing business logic as opposed to infrastructure services.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66154
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ak pillai:
You can acyiure it declaratively by specifying in your web.xml something like


acyiure?
 
ak pillai
author
Ranch Hand
Posts: 288
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Arul.

If we don't specify it in web.xml
is there any other way we can acquire datasource connection in our web application?

Regards,
Ajay.
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also do it from server.xml.

In Tomcat 5.5.8, you can put this tag within the innermost tag (<Host> tag)




Naseem
[ July 13, 2006: Message edited by: Naseem Khan ]
 
Scott Selikoff
author
Bartender
Posts: 4087
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could put it in a properties text file if you have a lot of other properties you need to store. It doesn't matter where you put it (web.xml, text file, or setup a database connection pool on the server*) as long as its not hardcoded into the java file.

*Best solution
 
Ajay Xavier
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi scott,
You could put it in a properties text file if you have a lot of other properties you need to store. It doesn't matter where you put it (web.xml, text file, or setup a database connection pool on the server*) as long as its not hardcoded into the java file.

Do you mean this?

We have to create a datasource in the Application server and bind it with a JNDI name. The Jndi name can be given either in the web.xml or a properties file.

Regards,
Ajay.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!