commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Firth <>
Subject Re: [DBCP] post createConnection() initialization.
Date Tue, 06 Aug 2002 11:38:06 GMT
"McKinstry, Pete (HQP)" <> wrote:

>Was any support ever added for running an initialization statement after
>creating a new connection? I needed something similar for calling "use
>schema ?" in db2, so I created an "InitializingConnectionFactory"

I have a vaguely similar problem - I will need to issue a "reset" to clear
any shared Oracle PL/SQL global variables when a connection is returned to
the pool (yukky I know.... but when their extensive use pre-dates your
involvement then one just has to work around it).

Further, I need to do it through BasicDataSource; subclassing
AbandonedObjectPool, PoolableConnection etc would be the easy fix that I
can't really do.  I thought about using testOnReturn... but the state
reset procedure can not be called from within an SQL query (in JDBC terms,
it must be invoked via a CallableStatement).

So, what I'm seeing is a possible want/need for "listeners" on certain

(invoked from borrowObject(), returnObject() & removeAbandoned()  in

(called from inside makeObject() in PoolableConnectionFactory)

The potential problem I see here is that all are synchronized methids ....  
What I am thinking is that without extra work, event listeners would only
be executed serially, whereas it might be possible to make the core tasks
of each method synchronised {like it should be to protect against
concurrent modifications!}, but allowing two concurrent borrows/return
requests to *start*, fire their listeners, then form a serial schedule
after the listener has returned and control hits the synchronized{} block
that wraps the rest of the method.  Thoughts anybody?

I'd be thinking of writing a "DBCPEventListener" interface, then
implementing the appropriate setters on AbandonedObjectPool,
PoolableConnectionFactory & BasicDataSource.  BasicDataSourceFactory would
actually instantiate listeners if supplied in the resource refs & pass
their instances into BasicDataSource's setters.

I'm also interested in Glen's reply that "support for a validation query
on connection creation was added to CVS 7/20".....  I might be going blind
but I can not really see where in the repository that change is....



(who still has to get around to writing some additional setters in
BasicDataSource to properly expose functionality like testOnBorrow,
testOnReturn, background connection validation checking etc etc... was it
really July 7 when I said I'd do that?  geez.)

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

View raw message