File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Store Connection Pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Store Connection Pool" Watch "Store Connection Pool" New topic
Author

Store Connection Pool

Lu�s Matos
Greenhorn

Joined: Nov 09, 2005
Posts: 12
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Lu�s Matos
Greenhorn

Joined: Nov 09, 2005
Posts: 12
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

Joined: Nov 09, 2005
Posts: 12
Hi Jeanne Boyarsky


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

Thanks
Lu�s Matos
Sri Ram
Ranch Hand

Joined: Oct 03, 2005
Posts: 118
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

Joined: Nov 09, 2005
Posts: 12
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

Joined: Nov 09, 2005
Posts: 12
Hi

Anyone know or use the example that Im talking about?

Thanks
Lu�s Matos
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Store Connection Pool