Re: OJB-DBCP initial connection pool setting support

Armin Waibel <[email protected]>
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi Eric,

Ferrer, Eric wrote:
> Armin,
> 
> I was just following up on this questions regarding being able to set
> the initial size of the pool on DBCP via the OJB.properties.  
> 
> If this can not be done in the current release, is there a plan to make
> it available or is there a work around?
> 

Yep, I'm working on this stuff (check in tomorrow).
A workaround could be to extend ConnectionFactoryDBCPImpl and to 
implement this behavior by overriding method setupPool (see below), 
declare the class in OJB.properties and using a custom-attribute 
"initialSize" within connection-pool element in repository file.
http://db.apache.org/ojb/docu/guides/repository.html#custom+attribute


> Could this be accomplished by switching from DBCP to JBOSS?  I have
> never used JBOSS connection pooling with OJB and would like to know if
> this has been tested and if there are any examples on how to configure
> OJB with JBOSS?
> 

I only use JBoss Datasources in managed environments (JTA). But I think 
it's possible to setup a JBoss connection-pool without JTA (but I never 
tried this).

regards,
Armin

###########
Workaround:
###########
public class ConnectionFactoryDBCPExtImpl extends ConnectionFactoryDBCPImpl
{
     private Logger log = 
LoggerFactory.getLogger(ConnectionFactoryDBCPImpl.class);

     protected ObjectPool setupPool(JdbcConnectionDescriptor jcd)
     {
         ObjectPool pool = super.setupPool(jcd);
         String initialSizeStr = 
jcd.getConnectionPoolDescriptor().getAttribute("initialSize", null);
         if(initialSizeStr != null && initialSizeStr.length() > 0)
         {
             int initialSize = Integer.parseInt(initialSizeStr);
             if(initialSize > 0)
             {
                 try
                 {
                     for (int i = 0 ; i < initialSize ; i++)
                     {
                         pool.addObject();
                     }
                 }
                 catch (Exception e)
                 {
                     log.error("Error preloading the connection pool 
(initialSize=" + initialSize + ")", e);
                 }
             }
         }
         return pool;
     }
}


> Thank you
> -Eric
> 
> -----Original Message-----
> From: Armin Waibel [mailto:[email protected]] 
> Sent: Thursday, September 21, 2006 1:30 PM
> To: OJB Users List
> Subject: Re: OJB-DBCP initial connection pool setting support
> 
> Hi Eric,
> 
> Ferrer, Eric wrote:
>> Hi,
>>
>>  
>>
>> DBCP supports an initialSize property for initializing connections on
>> startup, does OJB support this parameter?
>>
> 
> A DBCP property 'initialSize' is not supported. Could you point me at 
> the DBCP doc-section describe this property?
> 
> regards,
> Armin
> 
> 
>>  
>>
>> Thanks
>>
>> -Eric
>>
>>  
>>
>>  
>>
>> Disclaimer: 
>> This email may contain confidential and privileged material for the
> sole use of the intended recipient(s) and only for those purposes
> previously or herein authorized by the sender. Any review, use,
> distribution or disclosure by others, or use by the recipient for
> unauthorized purposes, is strictly prohibited. If you are not the
> intended recipient (or authorized to receive for the recipient), please
> contact the sender by reply email and delete all copies of this message.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> Disclaimer: 
> This email may contain confidential and privileged material for the sole use of the intended recipient(s) and only for those purposes previously or herein authorized by the sender. Any review, use, distribution or disclosure by others, or use by the recipient for unauthorized purposes, is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.