commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trenton D. Adams" <>
Subject Re: dbcp configurations
Date Wed, 23 Feb 2005 22:27:37 GMT
I figured it out.  The example helped 
quite a bit.  But, the documentation for how to get these things going 
is not easy to find, other than the examples and API.  But, a person 
shouldn't have to know the API all that well if all they want to do is 
use it. :)

I decided to go with the following...

     AbandonedConfig abandonedConfig;
     ObjectPool connectionPool;
     ConnectionFactory connectionFactory;
     PoolableConnectionFactory poolableConnectionFactory;
     PoolingDriver driver;

     // setup the abandoned configuration
     abandonedConfig = new AbandonedConfig();

     // setup the AbandonedObjectPool
     connectionPool = new AbandonedObjectPool(null, abandonedConfig);
     connectionFactory = new DriverManagerConnectionFactory(url,null);
     poolableConnectionFactory = new PoolableConnectionFactory(
         "SELECT 'ping' FROM dual",false,false);
       dbcpURL = "jdbc:apache:commons:dbcp:" + poolname;
       driver = (PoolingDriver) DriverManager.getDriver(dbcpURL);
       driver.registerPool(name, connectionPool);
     catch (Exception exception)
           "error creating DBCP connection pool");

This then allows a person to easily obtain a connection in the standard 
way like so...

connection = DriverManager.getConnection(dbcpURL)

poolname can be anything you like.  That way, the same JVM can use many 
different databases without worrying about the underlying driver or 
anything.  Just a reference to the poolname in the driver string and 
voila, you're in business.

Andre Van Klaveren wrote:
> Are you trying to configure it for use under Tomcat?
> Virtually,
> Andre Van Klaveren
> On Wed, 23 Feb 2005 09:45:55 -0700, Trenton D. Adams
> <> wrote:
>>Actually, that still doesn't get me anywhere because
>>"org.apache.commons.dbcp.PoolableConnectionFactory" doesn't have any
>>constructors that take abandoned configuration parameters.  Nor can I
>>pass an AbandonedObjectPool object to one if it's contructors because
>>that class's constructors don't take configuration parameters as parameters.
>>Trenton D. Adams wrote:
>>>Kle Miller pointed out how to get it working manually by constructing
>>>everything myself.  Which is probably what I'll do for now, until
>>>someone can tell me how the configuration file works.
>>>I found the JOCLContentHandler API documentation, which I had to
>>>generate, was quite helpful.  I think I can get it working with a
>>>configuration now.  Perhaps this documentation should be generated with
>>>the dbcp API documentation that's on the website?
>>>Trenton D. Adams wrote:
>>>>That list search really kinda bytes.  It can't find anything.  I'm sure
>>>>that what I'm about to ask has been asked many times.
>>>>Ok, we have the configuration items at the following address...
>>>>But, there's nothing telling me how to configure them.  The example jocl
>>>>configuration doesn't really say much.
>>>>See this...
>>>>   <!--
>>>>      The next argument is the query to use to validate that a
>>>>Connection is
>>>>      still up and running.  It should return at least one row.
>>>>      This functionality is optional. We'll just set it to null.
>>>>    -->
>>>>   <string null="true"/>
>>>>   <!-- The default "read only" value for Connections. -->
>>>>   <boolean value="false"/>
>>>>   <!-- The default "auto commit" value for Connections. -->
>>>>   <boolean value="true"/>
>>>>I don't see an SQL query there, yet the comment says there's a query to
>>>>validate the connection.
>>>>Further, I'm really confused by "<boolean value="false"/>"  what does
>>>>something like that do?  It's not associated with a configuration
>>>>parameter name or anything, how does that work?
>>>>There doesn't appear to be anywhere that tells me how to *glue*
>>>>everything together.  There's configuration item documentation,
>>>>there's an example jocl configuration, but nothing to tell me how I
>>>>put one of the configuration items into the config file.
>>>>All I'm trying to do is use a connection pool that supports removal
>>>>and tracing of abandoned connections.  Does anyone know how to get
>>>>this working?
>>Trenton D. Adams
>>Web Programmer Analyst
>>Navy Penguins at your service!
>>Athabasca University
>>(780) 675-6195
>>    This communication is intended for the use of the recipient to whom it
>>    is addressed, and may contain confidential, personal, and or privileged
>>    information. Please contact us immediately if you are not the intended
>>    recipient of this communication, and do not copy, distribute, or take
>>    action relying on it. Any communications received in error, or
>>    subsequent reply, should be deleted or destroyed.
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Trenton D. Adams
Web Programmer Analyst
Navy Penguins at your service!
Athabasca University
(780) 675-6195

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

View raw message