my dog learned polymorphism*
The moose likes JDBC and the fly likes Connection Pool (standalone/server) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Connection Pool (standalone/server)" Watch "Connection Pool (standalone/server)" New topic
Author

Connection Pool (standalone/server)

Fabricio Sanchez
Ranch Hand

Joined: Mar 11, 2003
Posts: 33
If I have a database installed in a machine which can be accessed by different machines on the network, how can connection pooling be achieved?
1. Is it possible for a ConnectionPool class to pool connections for all machines in the network? Or does each machine have to just manage its own connections and no-one else's?
2. Do I have to install a server like Apache/Tomcat, to be able to manage connections for ALL machines on the network?
Please note that this is in the context of JAVA APPLICATIONS, trying to connect directly to the database.
I hope this makes sense... thanx
Fabricio
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Connection pools are local to the JVM you're running on, so no, you can't pool several machine's JDBC connections (unless it's actually a cluster).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Fabricio:
I think there is a confusion as to what you are asking. From the post, it sounds to me that you think the connection pool is for database instead of your application.
Any modern database can support multiple connections at a time. So database is not the one that has to worry about pooling, it's your application. In this case, your application that needs multiple connections. So, your application is the one that needs to manage connectin pooling.
As for your question:
1. Is it possible for a ConnectionPool class to pool connections for all machines in the network? Or does each machine have to just manage its own connections and no-one else's?
The answer is yes and no, once again, it depends on your application. If your application is standalone that runs on each machine, then the answer is NO. On the other hand, if your application is web-based, and all your machines uses the web application, then you only need web application to handle connection pool. Also, in the third case, if you are running RMI, I never done this before, you should be able to get connection from remote pool.
2. Apcahe/Tomcat has nothing to do with pooling, it supports pooling, but for their own server environment.
One more point: depends on the complexity of your pooling class, it can be a nightmare to manage and trouble-shoot. I rarely seem a standalone application that requires more than a few connections. So the overhead for creating connection pool might not be worth it.
If you insist on using connection pool, try the jakarta common pooling and DBCP library. www.apache.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection Pool (standalone/server)