You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Ludovic Dubost <lu...@pobox.com> on 2004/02/26 01:12:04 UTC

Potential issue in commons dbcp

Hi,

I think I found a potential problem in commons dbcp and can't find where 
I should report it..
If you use the setCatalog function of JDBC you have an issue with the 
Prepared Statement Cache, since the cache considers that two statements 
with different catalogs are the same, and therefore returns wrong data..

My reproduction of the problem is:

0/ setup two databases (in my case it is mysql) with the same table with 
different a different amount of lines in the table
1/ open a connection
2/ run a query to count number of lines of the table
3/ switch databases using setCatalog
4/ run the same query
5/ you get the same result as before (the result from the 1st database)

Now if you do it the other way around, then you get the result from the 
second database..
I believe the problem can only come from the prepared statement cache..

Any thoughts ?
Ludovic

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


Re: Potential issue in commons dbcp

Posted by Dirk Verbeeck <di...@pandora.be>.
Excellent, good analysis and even a patch.

Any chance you could write a JUnit test ;-)

Thanks
Dirk

Ludovic Dubost wrote:
> I posted it in apache's bugzilla
> 
> http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27246
> 
> Ludovic
> 
> Ludovic Dubost wrote:
> 
>>
>> Hi,
>>
>> I think I found a potential problem in commons dbcp and can't find 
>> where I should report it..
>> If you use the setCatalog function of JDBC you have an issue with the 
>> Prepared Statement Cache, since the cache considers that two 
>> statements with different catalogs are the same, and therefore returns 
>> wrong data..
>>
>> My reproduction of the problem is:
>>
>> 0/ setup two databases (in my case it is mysql) with the same table 
>> with different a different amount of lines in the table
>> 1/ open a connection
>> 2/ run a query to count number of lines of the table
>> 3/ switch databases using setCatalog
>> 4/ run the same query
>> 5/ you get the same result as before (the result from the 1st database)
>>
>> Now if you do it the other way around, then you get the result from 
>> the second database..
>> I believe the problem can only come from the prepared statement cache..
>>
>> Any thoughts ?
>> Ludovic



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


Re: Potential issue in commons dbcp

Posted by Ludovic Dubost <lu...@pobox.com>.
I posted it in apache's bugzilla

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27246

Ludovic

Ludovic Dubost wrote:

>
> Hi,
>
> I think I found a potential problem in commons dbcp and can't find 
> where I should report it..
> If you use the setCatalog function of JDBC you have an issue with the 
> Prepared Statement Cache, since the cache considers that two 
> statements with different catalogs are the same, and therefore returns 
> wrong data..
>
> My reproduction of the problem is:
>
> 0/ setup two databases (in my case it is mysql) with the same table 
> with different a different amount of lines in the table
> 1/ open a connection
> 2/ run a query to count number of lines of the table
> 3/ switch databases using setCatalog
> 4/ run the same query
> 5/ you get the same result as before (the result from the 1st database)
>
> Now if you do it the other way around, then you get the result from 
> the second database..
> I believe the problem can only come from the prepared statement cache..
>
> Any thoughts ?
> Ludovic
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
>
>

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