commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bridges, Ed NYC" <EBrid...@citco.com>
Subject Re: DBCP: how to get reference to statement pool
Date Tue, 15 Mar 2005 23:15:54 GMT
 
I was trying to accomplish something similar recently, and Dirk passed onto
me this unit test for prepared statement pooling that helped to confirm
statement pooling was working properly.

HTH
--e--

-----Original Message-----
From: Dirk Verbeeck [mailto:dirk.verbeeck@pandora.be] 
Sent: Friday, February 25, 2005 1:39 PM
To: Jakarta Commons Users List
Subject: Re: [DBCP] Re: Repost: Help with PreparedStatement pooling

The mail with zipfile was rejected.
You can download the testcase here:
http://cvs.apache.org/~dirkv/DBCPTest.zip

-- Dirk


Dirk Verbeeck wrote:

> I now tried to reproduce you problem using the official release jars 
> in a new project but everything works as expected.
> 
> I'm attaching my test eclipse project. It is using the test driver 
> from dbcp test directories. You also need to include dbcp-1.2.1, 
> pool-1.2 and collections-3.1.
> 
> Let me know if this works for you.
> 
> -- Dirk
> 
> Edward Q. Bridges wrote:
> 
>>
>> Sorry for the repost, but after working with this further, I'm really 
>> stuck as to how I may confirm whether or not statement pooling is 
>> really working.
>>
>> As far as I can tell, I'm getting new instances (i.e. == is returning
>> false) of an innermost delegate statement for the same SQL query on 
>> the same connection.  This does not sound correct.  Maybe I'm missing 
>> something?
>>
>> Thanks in advance for any comments.
>>
>>
>> Edward Q. Bridges wrote:
>>
>>> Dirk, the code you provided isn't working for me (see below).
>>> I'm thinking that my configuration is wrong.  Can someone please 
>>> double check what I'm doing to configure it?  The complete 
>>> configuration is below, but here's the key part:
>>>
>>>       KeyedObjectPoolFactory stmtPoolFactory = new 
>>> GenericKeyedObjectPoolFactory(null);
>>>
>>>       PoolableConnectionFactory x = new PoolableConnectionFactory(
>>>               connFactory,
>>>               connPool,
>>>               stmtPoolFactory,
>>>               cfg.getValidationQuery(),
>>>               cfg.isDefaultReadOnly(),
>>>               cfg.isDefaultAutoCommit(),
>>>               cfg.getDefaultTransactionIsolation()
>>>       );
>>>
>>> Do I need to provide something else to the 
>>> GenericKeyedObjectPoolFactory
>>>
>>> besides a "null" value before giving it over to the 
>>> PoolableConnectionFactory?
>>>
>>>
>>>
>>> I copied and pasted what you provide as such:
>>>
>>>      conn = ds.getConnection();
>>>      stmt1 = conn.prepareStatement("select getDate()");
>>>      Statement ustmt1 = ((DelegatingStatement) stmt1)
>>>                                 .getInnermostDelegate();
>>>      stmt1.close();
>>>      stmt2 = conn.prepareStatement("select getDate()");
>>>      Statement ustmt2 = ((DelegatingStatement) stmt2)
>>>                                 .getInnermostDelegate();
>>>      stmt2.close();
>>>      assertSame(ustmt1, ustmt2);
>>>
>>> And I get this:
>>>
>>> junit.framework.AssertionFailedError:
>>>  expected same:<com.sybase.jdbc2.jdbc.SybPreparedStatement@19b5393>
>>>  was not:      <com.sybase.jdbc2.jdbc.SybPreparedStatement@8bdcd2>
>>>
>>> When I change to use assertEquals() (assertSame() uses "=="):
>>>
>>> junit.framework.AssertionFailedError:
>>>  expected:<com.sybase.jdbc2.jdbc.SybPreparedStatement@19b5393>
>>>  but was: <com.sybase.jdbc2.jdbc.SybPreparedStatement@8bdcd2>
>>>
>>> Thanks in advance.
>>> Ed
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message