jGuru
Register Email     Password Forgot your
password?
HOME FAQS FORUMS DOWNLOADS ARTICLES PEERSCOPE LEARN

  Search   jGuru Search Help

Question How can I pool my database connections so I don't have to keep reconnecting to the database?
Derived from A question posed by John Zukowski PREMIUM
Topics Java:API:JDBC
Author Sylvain GIBIER
Created Feb 22, 2000 Modified Mar 23, 2002


Answer

There are plenty of connection pool implementations described in books or availalble on the net.
Most of them implement the same model. The process is always the same :

  • you gets a reference to the pool
  • you gets a free connection from the pool
  • you performs your different tasks
  • you frees the connection to the pool

Since your application retrieves a pooled connection, you don't consume your time to connect / disconnect from your data source.
You can find some implementation of pooled connection over the net, for example:

  • Db Connection Broker (http://www.javaexchange.com/), a package quite stable ( I used it in the past to pool an ORACLE database on VMS system)
You can look at the JDBC 2.0 standard extension API specification from SUN which defines a number of additional concepts.


Is this item helpful?  yes  no     Previous votes   Yes: 1  No: 0



Comments and alternative answers

Comment on this FAQ entry

I highly recommend PoolMan. It comes with complete...
Christopher Longo, Jun 18, 2000  [replies:2]
I highly recommend PoolMan. It comes with complete source and is distributed under the Lesser Gnu Public License.

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Re: I highly recommend PoolMan. It comes with complete...
Gopalakrishnan G, May 5, 2001
Yes, PoolMan seems to do a lot at first. However, there is no documentation on how to use the product and there is no support. There are no examples available on how to use this product. It's frustating to say the least. If you know how to use it, then, please email me the details ggopalus@yahoo.com. Thanks

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
I am so sad,The poolman is no longer available!The text listed below was digisted from the site of poolMan
Jeason Zhao, Dec 13, 2002
PoolMan is no longer available or supported through this site. It did exceedingly well during its lifetime, and I appreciate the important role it played in so many distributed applications over the past three years. If you are looking for connection and object pooling mechanisms, they can now be found in application servers such as JRun, Tomcat and the Jakarta Project, and other J2EE products and servers.


Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
Additional connection pool resources: Enhydra Build...
Joe Sam Shirah PREMIUM, Jul 25, 2000
Additional connection pool resources:

Enhydra
Build your own ObjectPool in Java to boost app speed
THE JDBC 2.0 OPTIONAL PACKAGE
Improved Performance with a Connection Pool
Writing Advanced Applications: Chapter 8 Continued: Connection Pooling


Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  

Connection Pools
glenn bullock, May 7, 2002
Connection pools are nice, but most connections support concurrent statements, which is much simpler to deal with (unless you're dealing with transactions, of course).

Also, another nice idea is to have a Prepared Statement pool that will remove the statement from the map when needed (don't want to execute it simultaneously), then add it back in when you're done.



Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  
DBConnectionBroker Tips
Nate McMorris, Jun 26, 2002
DbConnectionBroker from javexchange(http://www.javaexchange.com) is working well. However...
There's almost no documentation. So here's what I found.
1) Start really simple, just create the broker object and NOTHING ELSE first.
2) When catching exceptions, use the method catching syntax ( public void method() throws Exception {...} ) rather than using a "try {} catch(){}" clause.
3) You must create your log file first. The Broker won't create it if it doesn't exist.
4) If you're running this inside a JSP/Servlet container, you can't rely on the container's class loader to find the database driver or any other classes you need from the DbConnectionBroker class; you need to make sure the DB Driver etc. is somewhere in your $CLASSPATH.
5) I needed to get this to work inside TOMCAT, and without using Servlets, so I create the broker between the <jsp:useBean...> and </jsp:useBean> tags, then I load that instance into a bean with an "application" cope. Then I can call that bean from any page where I need a connection.
6) I couldn't get some of the methods (like idOfConnection() ) to work, so try the methods out one by one to see if they work.
7) Lastly, the syntax for a MySQL connection is slightly different than the Oracle Driver in the examples. I use DbConnectionBroker myBroker = new DbConnectionBroker("org.gjt.mm.mysql.Driver","jdbc:mysql://yourdatabase server/yourDb?user=user","","",4,5,"/path/to/brokerLog.log",1.0,true,0,3);
-

Is this item helpful?  yes  no     Previous votes   Yes: 0  No: 0



Reply to this answer/comment  Help  


Ask A Question



 
Related Links

JDBC FAQ

JDBC Forum

Sun's JDBC pages

JDBC 2.0 optional package

Wish List
Features
About jGuru
Contact Us

 



The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers