• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Store Connection Pool

 
Lu�s Matos
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi Jeanne Boyarsky


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

Thanks
Lu�s Matos
 
Sri Ram
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Hi

Anyone know or use the example that Im talking about?

Thanks
Lu�s Matos
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic