struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David G. Friedman" <>
Subject RE: Connection Pool best practice
Date Wed, 19 Jan 2005 15:31:20 GMT

Do you make a new pool for every request?  That takes up a lot of resources.
Are you positive you are shutting down the pool and the connection when you
are done with them?  Ideally, you setup your pool once, store it in serlet
or application context, then use that on instance to hand you off a
"connection" and release that connection when you are done so it can be
reused.  That optimizes connection use and setup time.  From your below code
snippet and example, it feels like you are creating a pool in every request
so it takes time to talk to the database and open the connection.  Then, you
get a connection and have to close it AND the pool down or it eats up memory
and could invoke memory swapping related slowdown (if used in production or
in a stress test).  Again, that is the impression from the few lines of code


-----Original Message-----
From: Kalluru Uma. Maheswar []
Sent: Wednesday, January 19, 2005 5:22 AM
To: Struts Users Mailing List
Subject: Connection Pool best practice


I am using org.apache.commons.dbcp.BasicDataSource to implement a
connection pooling and this is my class.

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;

public class DBPool


            public DataSource getDataSource()


                    BasicDataSource ds = new BasicDataSource();







        return ds;



And in the classes where I need database connection, I am saying

DBPool dbPool = new DBPool();


By doing this, my application is getting slower. Initially I configured
db connection in the struts-config.xml file and it was working fast at
that time.

Any ways for me to improve the performance and speed?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message