This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code for Database connection

 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am developing an application using Java/JSP and web container is tomcat. Can anybody guide me how should I go abt writing connection class?
Is it ok to make connection through servlet init method?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4033
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to write your own connection class? Unless you're developing your own database, you generally want to use an exisitng Connection class with a JDBC driver that comes with your database.

I'd recommenting using lazy instantiation (only create it the first time you need it) for your database connection for two reasons: 1) better performance overall 2) better control- you can close it after you are done so that you dont run out of connections
 
Milan Jagatiya
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
better you refer below link ...and go for "JDBC Data Sources"...
it helps....
TOMCAT JNDI-RESOURCES
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help guys.Really Appreciate it!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic