|
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
 |
 |
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
|
|

|
 |
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
|
|

|
|
|
 |
|