• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Store Connection Pool

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im using one example of connection pool. The example have a servlet that I think make the management of the connections in the pool.
My problem is to use the servlet itself. Where I store the pool?
Actualy im storing the pool in one application variable but at the end of
some time with multiple online users I cant get more connections from the pool. I free the connections when I dont need any more, but the application variable is not the best solution.

Thanks
Lu�s Matos
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lu�s,
Welcome to JavaRanch!

Jakarta Commons implements a pool for you which makes things easier. If you are writing your own, you typically use a singeton which is stored in memory (like application scope.) Of the web app options (application, session, request, page), application is the broadest.

There may still be a resource leak even if you close connections. If you post that snippet of code, we can take a look.
 
Lu�s Matos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne Boyarsky

Thanks a lot for your response.

Im using the example of coreservlets. I think it very good but I dont know how to use it by the best way. I use the pool but I store the connections in application variable.
In this case if two user access to the page at the same time is possible that the pool dont work good.

Thanks
Lu�s Matos
 
Lu�s Matos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne Boyarsky


Do you know the example that I'm talking about?

Thanks
Lu�s Matos
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Y use Application Variable to store Connections?
U can Make Connection as a method variable and initialize the connection in every method and close it in finally block in the same method. Or Keep make it a Class variable and close the same at end of class. This way u can ensure that there is no leak. And also u wont run into NoMoreConnection problem.
 
Lu�s Matos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sriram TA

THanks for the reply.

Im storing the connections in one application variable, but this is not a good solution.

What I would like to know is how to use, for example, the connection pool of coreservlets in the right way, because Im using only partial.

Thanks
Lu�s Matos
 
Lu�s Matos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Anyone know or use the example that Im talking about?

Thanks
Lu�s Matos
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic