Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletContext and Connection Pool  RSS feed

 
mani dalal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sir,
Suppose I have more than one servlets in an application , each one of them wants to retrieve and psot data to DATABASE, do I need to instantiate use separate connection pool in the init method of each servlet.
OR can I use a single connection pool for all the servlet.If it is so, how do I pass the connection object created by a single connection pool instantiated in one servlet on on-load feature of web.xml of TOMCAT?Can I use ServletContext for ConnectionPool.
Please help me solve this.Also , explain me, in practical applications , how con pool is used?
Thanks,
Mani
 
pascal betz
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
yes, you can use one pool. Either use a NamingServer (as proposed with Datasource in JDBC 2, check the javasoft.com jdbc page), Application wide pool or implement it as a Singelton.
pascal
 
mani dalal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pascal,
Can you give me some more info or help me with a sample code for the same.
Thanks,
Mani
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DbConnectionBroker is a good connection pool manager and has examples for several ways to use it.
------------------
Hope This Helps
Carl Trusiak, SCJP2
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!