Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Parameters as Context Parameters?

 
Jenn Person
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have my JDBC parameters set as context parameters in my web.xml file as such:



Is this ok to do? Or a bad idea? I know it works, and did it primarily so I could maintain these attributes through just the web.xml file.
[ March 29, 2007: Message edited by: Jenn Person ]
 
Sunil Vasudevan
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is OK to do what you are doing.

But a better approach is to let your Web/App server handle database connections. They handle it in a more efficient manner.

Which web/app server are you using?
[ March 30, 2007: Message edited by: Sunil Vasudevan ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do not you use the connection pool provided by the container as Sunil mentioned? Or , if you want to go by this approach then it would be bettter to have a db.properties file within your application , which would have all the connection related parameters.
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is for learning purposes..how to use context parameters then it is fine..

But for an application in production environment ,it is better to go by what the others mentioned in the above posts...
 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks...

I am curious to learn things, what you mentioned as 'other' methods...

How does Container/Server Managed DB connections or connection pooling work...

Please advice me on the above
 
Jenn Person
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never used, or been aware of , a connection pool. I'll have to look into that.

Otherwise, besides less efficiency, are there any other setbacks to making them context parameters in terms of security perhaps?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not see and security threat to your approach as this (web.xml) would be within the WEB-INF directory.In fact I have worked on some application where some parameters are passed to the application using the init-param.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic