Bug 48392 - jdbc-pool is not returning the proxied connection in resultSet and statement
Summary: jdbc-pool is not returning the proxied connection in resultSet and statement
Status: RESOLVED FIXED
Alias: None
Product: Tomcat Modules
Classification: Unclassified
Component: jdbc-pool (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 critical (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 65932 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-12-15 11:43 UTC by gfernandes
Modified: 2022-03-07 23:50 UTC (History)
2 users (show)



Attachments
JdbcInterceptor to proxy resultSets and statements (6.22 KB, text/plain)
2009-12-16 11:26 UTC, gfernandes
Details
Statement decorator interceptor that proxies the resultSet and statement. (7.16 KB, text/x-java)
2010-02-24 18:06 UTC, gfernandes
Details
A correction to the createDecorator() method in the interceptor (10.27 KB, text/x-java)
2011-09-05 08:54 UTC, Neil Clarke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gfernandes 2009-12-15 11:43:20 UTC
The proxy connection returned by the jdbc-pool is not proxying the resultSet and the statement so if the client gets access to the underlying connection through: 

resultSet.getStatement().getConnection()

He is able to close the physical connection due to both instances (resultSet and statement) were not proxied. 
If this happens next time a client gets a connection from the jdbc-pool it will return a proxy with a physical connection closed.
Comment 1 gfernandes 2009-12-15 12:08:01 UTC
jdbc-pool version is: 1.0.7.1
Comment 2 gfernandes 2009-12-16 11:26:26 UTC
Created attachment 24713 [details]
JdbcInterceptor to proxy resultSets and statements

Implemented a JdbcInterceptor to proxy resultSets and statements.
Comment 3 Konstantin Kolinko 2009-12-16 19:10:14 UTC
For reference: link to the discussion thread on users@:
http://markmail.org/thread/lf4l3tjy5eev5kxo
http://marc.info/?t=126089853000004&r=1&w=2
Comment 4 Filip Hanik 2010-02-24 17:44:08 UTC
The patch contains a package name we can't use, and it doesn't have any license header in it.

Can you adjust the package name to 
org.apache.tomcat.jdbc.pool.interceptor

and add the license header (just look at an existing source file)
Comment 5 gfernandes 2010-02-24 18:06:13 UTC
Created attachment 25054 [details]
Statement decorator interceptor that proxies the resultSet and statement.

Corrected the package and added the license header as suggested by Filip.
Comment 6 Filip Hanik 2010-02-24 19:28:36 UTC
Thank you for the patch. It's been committed with a change to org.apache.juli.Log instead of Log4j
Comment 7 Neil Clarke 2011-09-05 08:54:34 UTC
Created attachment 27457 [details]
A correction to the createDecorator() method in the interceptor

There appears to be a typing error in the createDecorator() method of the interceptor, setting the connection to the constructor object:

statementProxy.setConnection(proxy);
statementProxy.setConstructor(constructor);
Comment 8 Filip Hanik 2011-09-12 15:25:29 UTC
Thank you
Fixed in r1169796
Comment 9 KMI 2019-11-13 13:01:43 UTC
Hi,


I'm using ddlutils 1.0 and tomcat jdbc pool 1.0.7.1 and I getting an error
due to a connection is closed and the pool is not aware of that.
Basically the issue is that ddlutils has a resultset iterator and when it
finishes it closes the connection by getting it from the *
resultSet.preparedStatement.connection* and the connection returned is not
the proxy that the pool has created.


So the issue happens when another client retrieves a connection from the
pool because the pool returns a connection that was actually closed.
Why tomcat jdbc pool is not creating proxies for preparedStatements and
resultSets like commons-dbcp?


Is there any other way to address this issue?

Thanks

Antonio - https://kmidata.es/
Comment 10 Alexey Kutishchev 2022-03-07 23:50:14 UTC
*** Bug 65932 has been marked as a duplicate of this bug. ***